/** * Folders only needs to be refreshed if it is the destination folder */ @Override protected boolean hasFolderChanged(AbstractFile folder) { return destFolder.equalsCanonical(folder); }
@Override public boolean equalsCanonical(Object f) { return file.equalsCanonical(f); }
@Override protected boolean hasFolderChanged(AbstractFile folder) { // This job modifies the folder where the archive is return folder.equalsCanonical(destFile.getParent()); // Note: parent may be null }
@Override protected boolean hasFolderChanged(AbstractFile folder) { // This job modifies the folder where the checksum file is return folder.equalsCanonical(checksumFile.getParent()); // Note: parent may be null }
/** * * @param sourceFile source file, can be null in which case the only collision checked against is {@link #DESTINATION_FILE_ALREADY_EXISTS}. * @param destFile destination file, cannot be null * @return an int describing the collision type, or {@link #NO_COLLOSION} if no collision was detected (see constants) */ public static int checkForCollision(AbstractFile sourceFile, AbstractFile destFile) { if(sourceFile!=null) { // Source and destination are equal if(destFile.equalsCanonical(sourceFile)) return SAME_SOURCE_AND_DESTINATION; // Both source and destination are folders and destination is a subfolder of source if(sourceFile.isParentOf(destFile)) return SOURCE_PARENT_OF_DESTINATION; } // File exists in destination if(destFile.exists() && !destFile.isDirectory()) return DESTINATION_FILE_ALREADY_EXISTS; return NO_COLLOSION; } }
boolean filesEqual = this.equalsCanonical(destFile); if(filesEqual) {
if(currentFolder != null && folder.equalsCanonical(currentFolder)) { markedFiles = tableModel.getMarkedFiles(); if(fileToSelect==null)
@Override protected void jobCompleted() { super.jobCompleted(); // If the destination files are located inside an archive, optimize the archive file AbstractArchiveFile archiveFile = baseDestFolder.getParentArchive(); if(archiveFile!=null && archiveFile.isArchive() && archiveFile.isWritable()) optimizeArchive((AbstractRWArchiveFile)archiveFile); // If this job corresponds to a 'local copy' of a single file and in the same directory, // select the copied file in the active table after this job has finished (and hasn't been cancelled) if(files.size()==1 && newName!=null && baseDestFolder.equalsCanonical(files.elementAt(0).getParent())) { // Resolve new file instance now that it exists: some remote files do not immediately update file attributes // after creation, we need to get an instance that reflects the newly created file attributes selectFileWhenFinished(FileFactory.getFile(baseDestFolder.getAbsolutePath(true)+newName)); } }
FolderPanel dragInitiator = DnDContext.getDragInitiator(); if(dragInitiator==folderPanel || dragInitiator.getCurrentFolder().equalsCanonical(folderPanel.getCurrentFolder())) {
if(sourceFile.equalsCanonical(destFile)) throw new FileTransferException(FileTransferError.SOURCE_AND_DESTINATION_IDENTICAL);
/** * Check and if needed, refreshes both file tables's current folders, based on the job's refresh policy. */ protected void refreshTables() { FolderPanel activePanel = getMainFrame().getActivePanel(); FolderPanel inactivePanel = getMainFrame().getInactivePanel(); if(hasFolderChanged(inactivePanel.getCurrentFolder())) inactivePanel.tryRefreshCurrentFolder(); if(hasFolderChanged(activePanel.getCurrentFolder())) { // Select file specified by selectFileWhenFinished (if any) only if the file exists in the active table's folder if(fileToSelect!=null && activePanel.getCurrentFolder().equalsCanonical(fileToSelect.getParent()) && fileToSelect.exists()) activePanel.tryRefreshCurrentFolder(fileToSelect); else activePanel.tryRefreshCurrentFolder(); } // Repaint the status bar as marked files have changed mainFrame.getStatusBar().updateSelectedFilesInfo(); }
@Override protected void jobCompleted() { super.jobCompleted(); // If the source files are located inside an archive, optimize the archive file AbstractArchiveFile sourceArchiveFile = getBaseSourceFolder()==null?null:getBaseSourceFolder().getParentArchive(); if(sourceArchiveFile!=null && sourceArchiveFile.isArchive() && sourceArchiveFile.isWritable()) optimizeArchive((AbstractRWArchiveFile)sourceArchiveFile); // If the destination files are located inside an archive, optimize the archive file, only if the destination // archive is different from the source one AbstractArchiveFile destArchiveFile = baseDestFolder.getParentArchive(); if(destArchiveFile!=null && destArchiveFile.isArchive() && destArchiveFile.isWritable() && !(sourceArchiveFile!=null && destArchiveFile.equalsCanonical(sourceArchiveFile))) optimizeArchive((AbstractRWArchiveFile)destArchiveFile); // If this job corresponds to a file renaming in the same directory, select the renamed file // in the active table after this job has finished (and hasn't been cancelled) if(files.size()==1 && newName!=null && baseDestFolder.equalsCanonical(files.elementAt(0).getParent())) { // Resolve new file instance now that it exists: some remote files do not immediately update file attributes // after creation, we need to get an instance that reflects the newly created file attributes selectFileWhenFinished(FileFactory.getFile(baseDestFolder.getAbsolutePath(true)+newName)); } }