Changeset 9052


Ignore:
Timestamp:
2005-02-16T10:12:22+13:00 (19 years ago)
Author:
mdewsnip
Message:

For some reason the lock file written when a collection is just created is different from that when the collection is reloaded. Worse, it wasn't valid XML so the tidied up parsing would barf on it. Now the same lock file is written is both circumstances, making everything a lot tidier.

File:
1 edited

Legend:

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

    r9045 r9052  
    203203    File lock_file = new File(collection_directory_path + LOCK_FILE);
    204204    lock_file.delete();
    205     if(lock_file.exists()) {
    206         System.err.println("Lockfile was not successfully deleted.");
     205    if (lock_file.exists()) {
     206        System.err.println("Warning: Lockfile was not successfully deleted.");
    207207    }
    208208
     
    443443        progress.setProgress(3);
    444444
    445         // Create a lock file.
    446         File lock_file = new File(collection_directory_path, LOCK_FILE);
    447         FileOutputStream out = new FileOutputStream(lock_file);
    448         out.write(LOCK_FILE.getBytes());
    449         out.close();
    450         out = null;
     445        // Create a lock file
     446        createLockFile(new File(collection_directory_path, LOCK_FILE));
    451447
    452448        progress.setProgress(4);
     
    460456
    461457
    462     public void createLockFile(File destination) {
     458    private void createLockFile(File lock_file)
     459    {
    463460    try {
    464461        Document default_lockfile = Utility.parse("xml/" + LOCK_FILE, true);
     
    478475        date_element = null;
    479476        date_time = null;
    480         XMLTools.writeXMLFile(destination, default_lockfile);
    481     }
    482     catch (Exception error) {
    483         DebugStream.printStackTrace(error);
     477        XMLTools.writeXMLFile(lock_file, default_lockfile);
     478    }
     479    catch (Exception exception) {
     480        DebugStream.printStackTrace(exception);
    484481    }
    485482    }
     
    488485    public boolean deleteCollection(String collection_name)
    489486    {
    490     File collection_directory = new File(getCollectionDirectoryPath(collection_name));
    491     return Utility.delete(collection_directory);
     487    return Utility.delete(new File(getCollectionDirectoryPath(collection_name)));
    492488    }
    493489
Note: See TracChangeset for help on using the changeset viewer.