Changeset 4608 for trunk


Ignore:
Timestamp:
2003-06-12T15:24:44+12:00 (21 years ago)
Author:
mdewsnip
Message:

Installing collections is now done with respect to the build mode option: selecting "all" (or not selecting anything) will remove the old index directory and make the building directory to become the new index directory. The other options merely move the contents of the building directory into the index directory, overwriting previous versions of the files/folders.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r4584 r4608  
    10861086    Gatherer.println("Build complete. Moving files.");
    10871087
    1088     // System.err.println("Build mode: " + collection.build_options.getBuildValue("mode"));
    10891088
    10901089    try {
     
    11031102        Gatherer.println("Build = " + build_dir.getAbsolutePath());
    11041103
    1105         // Remove the old index directory
    1106         if (index_dir.exists()) {
    1107         Utility.delete(index_dir);
     1104        // Get the build mode from the build options
     1105        String build_mode = collection.build_options.getBuildValue("mode");
     1106
     1107        // Special case for build mode "all": replace index dir with building dir
     1108        if (build_mode == null || build_mode.equals(get("CreatePane.Mode_All"))) {
     1109        // Remove the old index directory
    11081110        if (index_dir.exists()) {
    1109             throw new Exception("Index directory cannot be removed.");
    1110         }
    1111         }
    1112 
    1113         // Move the building directory to become the new index directory
    1114         build_dir.renameTo(index_dir);
    1115 
    1116         // Create a new building directory
    1117         File new_build = new File(getCollectionBuild(), "temp.txt");
    1118         new_build = new_build.getParentFile();
    1119 
    1120         if(new_build.exists()) {
    1121         throw(new Exception("Build directory cannot be moved."));
    1122         }
    1123 
    1124         new_build.mkdir();
     1111            Utility.delete(index_dir);
     1112            // Check the delete worked
     1113            if (index_dir.exists()) {
     1114            throw new Exception("Index directory cannot be removed.");
     1115            }
     1116        }
     1117
     1118        // Move the building directory to become the new index directory
     1119        if (build_dir.renameTo(index_dir) == false) {
     1120            throw new Exception("Build directory cannot be moved.");
     1121        }
     1122
     1123        // Create a new building directory
     1124        File new_build = new File(getCollectionBuild(), "temp.txt");
     1125        new_build = new_build.getParentFile();
     1126        new_build.mkdir();
     1127        }
     1128
     1129        // Otherwise copy everything in the building dir into the index dir
     1130        else {
     1131        File[] build_files = build_dir.listFiles();
     1132        for (int i = 0; i < build_files.length; i++) {
     1133            File build_file = build_files[i];
     1134            File index_equivalent = new File(index_dir, build_file.getName());
     1135
     1136            // Remove the old file in the index directory (if it exists)
     1137            if (index_equivalent.exists()) {
     1138            Utility.delete(index_equivalent);
     1139            // Check the delete worked
     1140            if (index_equivalent.exists()) {
     1141                throw new Exception("Index file " + index_equivalent + " cannot be removed.");
     1142            }
     1143            }
     1144
     1145            // Move the file into the index directory
     1146            if (build_file.renameTo(index_equivalent) == false) {
     1147            throw new Exception("File " + build_file + " cannot be moved into index directory.");
     1148            }
     1149        }
     1150        }
    11251151    }
    11261152    catch (Exception exception) {
Note: See TracChangeset for help on using the changeset viewer.