Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

dirlisting for all empty directories. no problem to update dir.java anymore, because its only in htroot/htdocsdefault needed. migration to delete old dir.* files in the fileshare

allo879587580046
diff --git a/ChangeLog b/ChangeLog
index 44e5fabcf..cb77c4201 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@ version 0.46
* ADDED: Form-Login on User.html
* ADDED: nice Errorpage for httpauth-fail.
* ADDED: support to generate gettext locales and parse them.
+ * CHANGED: new dirlisting support for empty directories instead of copying dir.* into them.
version 0.45
* UPDATED: new Design of search page
diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.java
index b8818c931..ce9300bea 100644
--- a/source/de/anomic/http/httpdFileHandler.java
+++ b/source/de/anomic/http/httpdFileHandler.java
@@ -439,17 +439,21 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
// attach default file name
for (int i = 0; i < defaultFiles.length; i++) {
testpath = path + defaultFiles[i];
- targetFile = getLocalizedFile(testpath);
- targetClass = rewriteClassFile(new File(htDefaultPath, testpath));
- if (!(targetFile.exists())){
- targetFile = new File(htDocsPath, testpath);
- targetClass = rewriteClassFile(targetFile);
- }
+ targetFile = getOverlayedFile(testpath);
+ targetClass=getOverlayedClass(testpath);
if (targetFile.exists()) {
path = testpath;
break;
}
}
+ //no defaultfile, send a dirlisting
+ if(targetFile == null || !targetFile.exists()){
+ targetFile = getOverlayedFile("/htdocsdefault/dir.html");
+ targetClass=getOverlayedClass("/htdocsdefault/dir.html");
+ if(! (( targetFile != null && targetFile.exists()) && ( targetClass != null && targetClass.exists())) ){
+ httpd.sendRespondError(this.connectionProperties,out,3,500,"dir.html or dir.class not found.",null,null);
+ }
+ }
}else{
//XXX: you cannot share a .png/.gif file with a name like a class in htroot.
if ( !(targetFile.exists()) && !((path.endsWith("png")||path.endsWith("gif")||path.endsWith(".stream"))&&targetClass!=null ) ){
@@ -572,14 +576,15 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
path.endsWith("rss") ||
path.endsWith("csv") ||
path.endsWith("pac") ||
- path.endsWith("src")) {
+ path.endsWith("src") ||
+ path.endsWith("/")) {
- targetFile = getLocalizedFile(path);
+ /*targetFile = getLocalizedFile(path);
if (!(targetFile.exists())) {
// try to find that file in the htDocsPath
File trialFile = new File(htDocsPath, path);
if (trialFile.exists()) targetFile = trialFile;
- }
+ }*/
// call rewrite-class
@@ -878,6 +883,25 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
}
}
}
+
+ private File getOverlayedClass(String path) {
+ File targetClass;
+ targetClass=rewriteClassFile(new File(htDefaultPath, path)); //works for default and localized files
+ if(targetClass == null || !targetClass.exists()){
+ //works for htdocs
+ targetClass=rewriteClassFile(new File(htDocsPath, path));
+ }
+ return targetClass;
+ }
+
+ private File getOverlayedFile(String path) {
+ File targetFile;
+ targetFile = getLocalizedFile(path);
+ if (!(targetFile.exists())){
+ targetFile = new File(htDocsPath, path);
+ }
+ return targetFile;
+ }
private void forceConnectionClose() {
if (this.connectionProperties != null) {
diff --git a/source/migration.java b/source/migration.java
index 918bb6733..5befc912e 100644
--- a/source/migration.java
+++ b/source/migration.java
@@ -50,6 +50,7 @@ public class migration {
//SVN constants
public static final int USE_WORK_DIR=1389; //wiki & messages in DATA/WORK
public static final int TAGDB_WITH_TAGHASH=1635; //tagDB keys are tagHashes instead of plain tagname.
+ public static final int NEW_DIRLISTING_OVERLAY=2294;
public static void main(String[] args) {
}
@@ -62,6 +63,17 @@ public class migration {
if(fromRev < toRev){
if(fromRev < TAGDB_WITH_TAGHASH){
migrateBookmarkTagsDB(sb);
+ }
+ if(fromRev < NEW_DIRLISTING_OVERLAY){
+ File file=new File(sb.htDocsPath, "share/dir.html");
+ if(file.exists())
+ file.delete();
+ file=new File(sb.htDocsPath, "share/dir.class");
+ if(file.exists())
+ file.delete();
+ file=new File(sb.htDocsPath, "share/dir.java");
+ if(file.exists())
+ file.delete();
}
serverLog.logInfo("MIGRATION", "Migrating from "+String.valueOf(fromRev)+ " to "+String.valueOf(toRev));
installSkins(sb);
diff --git a/source/yacy.java b/source/yacy.java
index 6daccc7b2..949a34569 100644
--- a/source/yacy.java
+++ b/source/yacy.java
@@ -348,14 +348,6 @@ public final class yacy {
final File shareDefaultPath = new File(htDocsPath, "share");
if (!(shareDefaultPath.exists())) shareDefaultPath.mkdir();
- final File shareDefaultClass = new File(shareDefaultPath, "dir.class");
- //if ((!(shareDefaultClass.exists())) || (shareDefaultClass.length() != (new File(htRootPath, "htdocsdefault/dir.class")).length())) try {
- if((new File(htRootPath, "htdocsdefault/dir.java")).exists())
- serverFileUtils.copy(new File(htRootPath, "htdocsdefault/dir.java"), new File(shareDefaultPath, "dir.java"));
- serverFileUtils.copy(new File(htRootPath, "htdocsdefault/dir.class"), shareDefaultClass);
- serverFileUtils.copy(new File(htRootPath, "htdocsdefault/dir.html"), new File(shareDefaultPath, "dir.html"));
- //} catch (IOException e) {}
-
migration.migrate(sb, oldRev, newRev);
// start main threads