Changeset 22807

Show
Ignore:
Timestamp:
30.08.2010 19:32:02 (9 years ago)
Author:
ak19
Message:

Fixed a bug in GLI where we weren't able to delete a collection just built (even without any docs in it) and which had just been closed. The reason was that the build_log file was never properly closed until a new collection was opened, at which point we could finally delete the previously closed collection. Now on CollectionManager?.closeCollection(), GLI ensures that any currently active build_log in OptionsPane? is closed (which calls the new close method in AppendLineOnlyFileDocument?.

Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
3 modified

Legend:

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

    r22780 r22807  
    418418        Gatherer.remoteGreenstoneServer.deleteCollectionFile(collection.getGroupQualifiedName(false), lock_file); 
    419419    } 
     420     
     421    //  release the current build_log file - else we're unable to delete the last closed collection  
     422    // until another collection is opened and its opening a new build_log closes this old one 
     423    Gatherer.g_man.create_pane.options_pane.closeCurrentLogDocument(); 
    420424 
    421425    MetadataSetManager.clearMetadataSets(); 
  • main/trunk/gli/src/org/greenstone/gatherer/gui/OptionsPane.java

    r21787 r22807  
    377377    return file_entry.getDocument(); 
    378378    } 
     379     
     380    /** ensure the current build_log file has finished transferring from memory to disk, and that the random access 
     381    *  file is properly closed when a collection is closed.  Else we can't delete the just-closed collection since the  
     382    * build_log file resource is still kept open. */ 
     383    public void closeCurrentLogDocument() { 
     384        if(file_entry == null) { 
     385            return; 
     386        } 
     387        AppendLineOnlyFileDocument buildDoc = file_entry.getDocument(); 
     388        if(buildDoc != null) { 
     389            buildDoc.close(); 
     390        }        
     391    } 
    379392 
    380393 
  • main/trunk/gli/src/org/greenstone/gatherer/util/AppendLineOnlyFileDocument.java

    r15862 r22807  
    172172    } 
    173173 
     174    /** ensure the current build_log file has finished transferring from memory to disk, and that the random access 
     175    * file is properly closed when a collection is closed.  Else we can't delete the just-closed collection since the  
     176    * build_log file resource is still kept open. */ 
     177    public void close() { 
     178        if(writer == null) { // closed already 
     179            return; 
     180        } 
     181        // get rid of the writer and then close the file 
     182        setExit(); 
     183        writer = null; 
     184        try {    
     185            file.close(); 
     186        } catch(Exception exception) { 
     187            DebugStream.println("Exception in AppendLineOnlyFileDocument.close() - Unable to close internal file"); 
     188            DebugStream.printStackTrace(exception); 
     189        } 
     190    } 
     191     
    174192    /** The destructor is implemented to ensure the current log file has finished transferring from memory to disk, and that the random access file is properly closed, before GLI exits. 
    175193     * @see org.greenstone.gatherer.util.AppendLineOnlyFileDocument.WriterThread#finish 
     
    177195    public void destroy() { 
    178196    try { 
    179         writer.finish(); 
    180         file.close(); 
     197        if(writer != null) { 
     198            writer.finish(); 
     199            writer = null; 
     200            file.close(); 
     201        } 
    181202    } 
    182203    catch(Exception exception) {