Ignore:
Timestamp:
2010-08-30T19:32:02+12:00 (14 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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) {
Note: See TracChangeset for help on using the changeset viewer.