Changeset 37691


Ignore:
Timestamp:
2023-04-20T22:04:00+12:00 (12 months ago)
Author:
anupama
Message:

Second part of Dr Bainbridge's request for dealing with any existing archives_keepold folder on pressing build button in GLI: user should be presented with dialog. Have tested by creating a manual copy of archives name as archives_keepold to trigger new functionality on pressing build button. But, since the rename of keepold to archives is very fast, I still need to test if it is indeed the keepold that's been renamed to archives after deleting existing archives.

Location:
main/trunk/gli/src/org/greenstone/gatherer/gui
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/gui/CreatePane.java

    r37690 r37691  
    633633        if(event.getType() == GShell.IMPORT &&
    634634           (event.getStatus() == GShell.CANCELLED || event.getStatus() == GShell.ERROR)) {
    635         //System.err.println("********* in processComplete CANCELLED IMPORT");
    636635        moveAnyKeepOldToArchives();
    637636        }
     
    663662        File archives_dir = new File(archives);
    664663       
    665         if(archives_dir.exists()) {         
    666             // no special behaviour for remote GS or fedora. The minimal (incr) rebuild
    667             // button is already disabled for remote GS.
    668            
    669             // Locally delete archives dir, and if that worked, rename keepold
    670             if(Utility.delete(archives_dir)) {
    671             // move "archives_keepold" to "archives"
    672             if(!archives_keepold_dir.renameTo(archives_dir)) {
    673                 statusMsg = "Failed to rename " + archives_keepold_dir
    674                 + "\n  to " + archives_dir;
    675                 //document.appendLine(statusMsg);
    676                 System.err.println(statusMsg);
    677                 this.shell.fireMessage(statusMsg);
    678             }
    679             } else {
    680             statusMsg = "Failed to delete " + archives_dir
    681                 + "  in attempt to rename archives_keepold to archives";
    682             //document.appendLine(statusMsg);
     664        // no special behaviour for remote GS or fedora. The minimal (incr) rebuild
     665        // button is already disabled for remote GS.
     666       
     667        // First locally delete archives dir if any exists
     668        if(archives_dir.exists() && !Utility.delete(archives_dir)) {           
     669            statusMsg = "Failed to delete " + archives_dir
     670            + "  in attempt to rename archives_keepold to archives";
     671            System.err.println(statusMsg);
     672            this.shell.fireMessage(statusMsg);
     673        }     
     674
     675        if(!archives_dir.exists()) {
     676            // Rename archives_keepold folder to archives
     677            if(!archives_keepold_dir.renameTo(archives_dir)) {
     678            statusMsg = "Failed to rename " + archives_keepold_dir
     679                + "\n  to " + archives_dir;
    683680            System.err.println(statusMsg);
    684681            this.shell.fireMessage(statusMsg);
    685             }       
    686         }
    687         // do what the message() method does after appending to document (build log)
    688         //log_textarea.setCaretPosition(document.getLengthToNearestLine());
     682            }
     683        }       
    689684        }
    690685    }
     
    760755        Collection collection = Gatherer.c_man.getCollection();
    761756        String collection_name = collection.getName();
     757
     758    // Take care of the case if we have a stray archives_keepold folder
     759    File archives_keepold_dir = new File(CollectionManager.getLoadedCollectionArchivesKeepOldDirectoryPath());
     760    if(archives_keepold_dir.exists()) {
     761        WarnIncrBuildDialog dialog = new WarnIncrBuildDialog();
     762        int result = dialog.display();
     763        dialog.dispose();
     764        dialog = null;
     765        if(result == WarnIncrBuildDialog.CANCEL) { // user chose not to build after all
     766        return;
     767        }
     768    }
    762769
    763770        //if button is labelled for Building
Note: See TracChangeset for help on using the changeset viewer.