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

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2294 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
allo 19 years ago
parent 45cefedd35
commit 8795875800

@ -5,6 +5,7 @@ version 0.46
* ADDED: Form-Login on User.html * ADDED: Form-Login on User.html
* ADDED: nice Errorpage for httpauth-fail. * ADDED: nice Errorpage for httpauth-fail.
* ADDED: support to generate gettext locales and parse them. * 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 version 0.45
* UPDATED: new Design of search page * UPDATED: new Design of search page

@ -439,17 +439,21 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
// attach default file name // attach default file name
for (int i = 0; i < defaultFiles.length; i++) { for (int i = 0; i < defaultFiles.length; i++) {
testpath = path + defaultFiles[i]; testpath = path + defaultFiles[i];
targetFile = getLocalizedFile(testpath); targetFile = getOverlayedFile(testpath);
targetClass = rewriteClassFile(new File(htDefaultPath, testpath)); targetClass=getOverlayedClass(testpath);
if (!(targetFile.exists())){
targetFile = new File(htDocsPath, testpath);
targetClass = rewriteClassFile(targetFile);
}
if (targetFile.exists()) { if (targetFile.exists()) {
path = testpath; path = testpath;
break; 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{ }else{
//XXX: you cannot share a .png/.gif file with a name like a class in htroot. //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 ) ){ 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("rss") ||
path.endsWith("csv") || path.endsWith("csv") ||
path.endsWith("pac") || path.endsWith("pac") ||
path.endsWith("src")) { path.endsWith("src") ||
path.endsWith("/")) {
targetFile = getLocalizedFile(path); /*targetFile = getLocalizedFile(path);
if (!(targetFile.exists())) { if (!(targetFile.exists())) {
// try to find that file in the htDocsPath // try to find that file in the htDocsPath
File trialFile = new File(htDocsPath, path); File trialFile = new File(htDocsPath, path);
if (trialFile.exists()) targetFile = trialFile; if (trialFile.exists()) targetFile = trialFile;
} }*/
// call rewrite-class // call rewrite-class
@ -879,6 +884,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() { private void forceConnectionClose() {
if (this.connectionProperties != null) { if (this.connectionProperties != null) {
this.connectionProperties.setProperty(httpHeader.CONNECTION_PROP_PERSISTENT,"close"); this.connectionProperties.setProperty(httpHeader.CONNECTION_PROP_PERSISTENT,"close");

@ -50,6 +50,7 @@ public class migration {
//SVN constants //SVN constants
public static final int USE_WORK_DIR=1389; //wiki & messages in DATA/WORK 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 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) { public static void main(String[] args) {
} }
@ -62,6 +63,17 @@ public class migration {
if(fromRev < toRev){ if(fromRev < toRev){
if(fromRev < TAGDB_WITH_TAGHASH){ if(fromRev < TAGDB_WITH_TAGHASH){
migrateBookmarkTagsDB(sb); 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)); serverLog.logInfo("MIGRATION", "Migrating from "+String.valueOf(fromRev)+ " to "+String.valueOf(toRev));
installSkins(sb); installSkins(sb);

@ -348,14 +348,6 @@ public final class yacy {
final File shareDefaultPath = new File(htDocsPath, "share"); final File shareDefaultPath = new File(htDocsPath, "share");
if (!(shareDefaultPath.exists())) shareDefaultPath.mkdir(); 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); migration.migrate(sb, oldRev, newRev);
// start main threads // start main threads

Loading…
Cancel
Save