Ignore:
Timestamp:
2003-12-19T14:20:20+13:00 (20 years ago)
Author:
kjdon
Message:

now checking whether index can be deleted before importing - so dont waste time doing the build when cant copy it over anyway

File:
1 edited

Legend:

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

    r6153 r6317  
    189189    }
    190190    return false;
     191    }
     192
     193    /** a test method to see if we can delete a directory/file - returns false is the file or any of the contents of a directory cannot be deleted */
     194    public boolean canDelete(File file) {
     195    if (!file.isDirectory()) {
     196        return file.canWrite();
     197    }
     198    File [] file_list = file.listFiles();
     199    for (int i=0; i<file_list.length; i++) {
     200        if (!canDelete(file_list[i])) {
     201        return false;
     202        }
     203    }
     204    return true;
    191205    }
    192206    /** Called to close the current collection and remove its lock file.
     
    704718    else {
    705719        importing = true;
     720        //check that we can remove the old index before starting import
     721        File index_dir = new File(getCollectionIndex(), "temp.txt");
     722        index_dir = index_dir.getParentFile();
     723        if(index_dir.exists()) {
     724           Gatherer.println("Old Index = " + index_dir.getAbsolutePath()+", testing for deletability");
     725           if (!canDelete(index_dir)) {
     726           // tell the user
     727           JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Cannot_Delete_Index"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     728           // tell the gui manager
     729           // a message for the building log
     730           GShellEvent event = new GShellEvent(this, 0, GShell.IMPORT, Dictionary.get("CollectionManager.Cannot_Delete_Index_Log"), GShell.ERROR);
     731           Gatherer.g_man.create_pane.message(event);
     732           event = new GShellEvent(this, 0, GShell.IMPORT, "", GShell.ERROR);
     733           Gatherer.g_man.create_pane.processComplete(event);
     734           importing = false;
     735           return;
     736           }
     737           
     738        }
     739
    706740        // Remove erroneous file windows file separator as it causes problems when running import.pl
    707741        String collection_import = getCollectionImport();
Note: See TracChangeset for help on using the changeset viewer.