Changeset 4584 for trunk/gli


Ignore:
Timestamp:
2003-06-11T16:40:23+12:00 (21 years ago)
Author:
mdewsnip
Message:

Changed saving a collection so it doesn't happen in its own thread - this was sometimes causing nasty race conditions when loading an old collection or opening a new one.

File:
1 edited

Legend:

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

    r4557 r4584  
    178178     */
    179179    public void closeCollection() {
     180    // System.err.println("Closing collection...");
    180181    // Remove the lock on this file, then remove the collection.
    181182    File lock_file = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator + LOCK_FILE);
     
    188189    Gatherer.config.setCollectionConfiguration(null);
    189190    Gatherer.g_man.collectionChanged(false);
     191    // System.err.println("Closed collection.");
    190192    }
    191193
     
    612614        current_collection_directory = Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName();
    613615    }
     616
    614617    // Create the workspace tree.
    615618    FileNode workspace_root = new FileNode("ABS_ROOT");
     
    625628    // We add their import and gimport directories, but only if its not our current collection.
    626629    for(int i = 0; cols != null && i < cols.length; i++) {
    627         ///ystem.err.println(current_collection_directory);
    628         ///ystem.err.println(cols[i].getName() + " = modelcol");
     630        ///ystem.err.print("Collection: " + collection);
     631        ///ystem.err.print(" Current collection dir: " + current_collection_directory);
     632        ///ystem.err.print(" Col " + i + " : " + cols[i] + "\n");
    629633        if(collection == null || (!current_collection_directory.equals(cols[i].getAbsolutePath()) && !cols[i].getName().equals("modelcol"))) {
    630634        File dirs[] = cols[i].listFiles();
     
    779783            // Open the collection file
    780784            collection = new Collection(collection_file);
     785            // System.err.println("In CollectionManager::loadCollection(), collection: " + collection);
    781786            collection.msm = new MetadataSetManager();
    782787            msm = collection.msm; // Legacy
     
    794799            }
    795800            result = true;
     801            // System.err.println("Done loadCollection().");
    796802            } catch (Exception error) {
    797803            // There is obviously no existing collection present.
     
    9971003    try {
    9981004        SaveCollectionTask save_task = new SaveCollectionTask(collection, close_after, exit_after);
    999         save_task.start();
     1005        // Run this in the same thread
     1006        save_task.run();
    10001007    }
    10011008    catch(Exception error) {
     
    10781085    private void installCollection() {
    10791086    Gatherer.println("Build complete. Moving files.");
    1080          
     1087
     1088    // System.err.println("Build mode: " + collection.build_options.getBuildValue("mode"));
     1089
    10811090    try {
    10821091                // We have to ensure that the local library
     
    10851094        Gatherer.g_man.preview_pane.configServer(GSDLSiteConfig.RELEASE_COMMAND + collection.getName());
    10861095        }
    1087                
     1096
    10881097        File index_dir = new File(getCollectionIndex(), "temp.txt");
    10891098        index_dir = index_dir.getParentFile();
    10901099        Gatherer.println("Index = " + index_dir.getAbsolutePath());
    1091                
    1092         if(index_dir.exists()) {
    1093         Utility.delete(index_dir);
    1094         }
    1095 
    1096         if(index_dir.exists()) {
    1097         throw(new Exception("Index directory cannot be removed."));
    1098         }
    1099                
     1100
    11001101        File build_dir = new File(getCollectionBuild(), "temp.txt");
    11011102        build_dir = build_dir.getParentFile();
    11021103        Gatherer.println("Build = " + build_dir.getAbsolutePath());
     1104
     1105        // Remove the old index directory
     1106        if (index_dir.exists()) {
     1107        Utility.delete(index_dir);
     1108        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
    11031114        build_dir.renameTo(index_dir);
    11041115
     1116        // Create a new building directory
    11051117        File new_build = new File(getCollectionBuild(), "temp.txt");
    11061118        new_build = new_build.getParentFile();
Note: See TracChangeset for help on using the changeset viewer.