Changeset 24636


Ignore:
Timestamp:
09/23/11 13:37:54 (10 years ago)
Author:
ak19
Message:

FileQueue.copyDirectoryContents is now overloaded to take an overwrite parameter. This is necessary for when CollectionManager.copyExtraBaseCollStuff() has to copy the macros folder across. At this point a new collection contains a macros folder already and it used to be unable to overwite it before. Now, with the new overwrite flag to FileQueue.copyDirContents(), setting overwrite to true when basing a new collection on an existing one allows all the necessary folders to be copied across.

Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
2 edited

Legend:

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

    r23433 r24636  
    485485          File new_coll_subdir = new File(new_coll_dir, dir_name);
    486486          new_coll_subdir.mkdirs();
    487           Gatherer.f_man.getQueue().copyDirectoryContents(subdir, new_coll_subdir);
     487          // Copy with force overwrite, since it's a new collection that's currently
     488          // being created and won't have anything in it but at most modelcol stuff
     489          Gatherer.f_man.getQueue().copyDirectoryContents(subdir, new_coll_subdir, true);
    488490        }
    489491        catch (Exception e) {
  • main/trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java

    r22605 r24636  
    727727     * @see org.greenstone.gatherer.Gatherer
    728728     */
    729     public void copyDirectoryContents(File source, File destination)
     729    public void copyDirectoryContents(File source, File destination, boolean overwrite)
    730730    throws FileAlreadyExistsException, FileNotFoundException, InsufficientSpaceException, IOException, ReadNotPermittedException, UnknownFileErrorException, WriteNotPermittedException
    731731    {
     
    741741        File new_file = new File(destination, f_name);
    742742        if (f.isDirectory()) {
    743         copyDirectoryContents(f, new_file);
     743        copyDirectoryContents(f, new_file, overwrite);
    744744        } else if (f.isFile()) {
    745         copyFile(f, new_file, false);
    746         }
    747     }
     745        copyFile(f, new_file, overwrite);
     746        }
     747    }
     748    }
     749
     750    /** Preserving old default behaviour of copyDirContents method, where overwrite is false. */
     751    public void copyDirectoryContents(File source, File destination) throws FileAlreadyExistsException, FileNotFoundException, InsufficientSpaceException, IOException, ReadNotPermittedException, UnknownFileErrorException, WriteNotPermittedException
     752    {
     753    copyDirectoryContents(source, destination, false);
    748754    }
    749755
Note: See TracChangeset for help on using the changeset viewer.