Search in sources :

Example 16 with RemoteFile

use of org.syncany.plugins.transfer.files.RemoteFile in project syncany by syncany.

the class PathAwareFeatureTransferManager method delete.

@Override
public boolean delete(final RemoteFile remoteFile) throws StorageException {
    RemoteFile pathAwareRemoteFile = createPathAwareRemoteFile(remoteFile);
    boolean fileDeleted = underlyingTransferManager.delete(pathAwareRemoteFile);
    boolean folderDeleted = removeFolder(pathAwareRemoteFile);
    return fileDeleted && folderDeleted;
}
Also used : RemoteFile(org.syncany.plugins.transfer.files.RemoteFile) MultichunkRemoteFile(org.syncany.plugins.transfer.files.MultichunkRemoteFile)

Example 17 with RemoteFile

use of org.syncany.plugins.transfer.files.RemoteFile in project syncany by syncany.

the class RemoteTransaction method deleteTempRemoteFiles.

/**
	 * This method deletes the temporary remote files that were the result of deleted files.
	 * 
	 * Actually deleting remote files is done after finishing the transaction, because
	 * it cannot be rolled back! If this fails, the temporary files will eventually
	 * be cleaned up by Cleanup and download will not download these, because
	 * they are not in any transaction file.
	 */
private void deleteTempRemoteFiles() throws StorageException {
    boolean success = true;
    for (ActionTO action : transactionTO.getActions()) {
        if (action.getStatus().equals(ActionStatus.STARTED)) {
            // If we are resuming, this action has not been comopleted.
            if (action.getType().equals(ActionType.DELETE)) {
                RemoteFile tempRemoteFile = action.getTempRemoteFile();
                logger.log(Level.INFO, "- Deleting temp. file {0}  ...", new Object[] { tempRemoteFile });
                try {
                    transferManager.delete(tempRemoteFile);
                } catch (Exception e) {
                    logger.log(Level.INFO, "Failed to delete: " + tempRemoteFile, " because of: " + e);
                    success = false;
                }
                action.setStatus(ActionStatus.DONE);
            }
        }
    }
    if (success) {
        logger.log(Level.INFO, "END of TX.delTemp(): Sucessfully deleted final files.");
    } else {
        logger.log(Level.INFO, "END of TX.delTemp(): Did not succesfully delete all files!");
    }
}
Also used : ActionTO(org.syncany.plugins.transfer.to.ActionTO) RemoteFile(org.syncany.plugins.transfer.files.RemoteFile) TempRemoteFile(org.syncany.plugins.transfer.files.TempRemoteFile) TransactionRemoteFile(org.syncany.plugins.transfer.files.TransactionRemoteFile)

Example 18 with RemoteFile

use of org.syncany.plugins.transfer.files.RemoteFile in project syncany by syncany.

the class AbstractTransferManagerTest method cleanTestLocation.

private void cleanTestLocation(TransferManager transferManager) throws StorageException {
    Map<String, RemoteFile> normalFiles = transferManager.list(RemoteFile.class);
    Map<String, DatabaseRemoteFile> databaseFiles = transferManager.list(DatabaseRemoteFile.class);
    Map<String, MultichunkRemoteFile> multiChunkFiles = transferManager.list(MultichunkRemoteFile.class);
    for (RemoteFile remoteFile : normalFiles.values()) {
        transferManager.delete(remoteFile);
    }
    for (RemoteFile remoteFile : databaseFiles.values()) {
        transferManager.delete(remoteFile);
    }
    for (RemoteFile remoteFile : multiChunkFiles.values()) {
        transferManager.delete(remoteFile);
    }
}
Also used : MultichunkRemoteFile(org.syncany.plugins.transfer.files.MultichunkRemoteFile) DatabaseRemoteFile(org.syncany.plugins.transfer.files.DatabaseRemoteFile) RemoteFile(org.syncany.plugins.transfer.files.RemoteFile) MasterRemoteFile(org.syncany.plugins.transfer.files.MasterRemoteFile) DatabaseRemoteFile(org.syncany.plugins.transfer.files.DatabaseRemoteFile) MultichunkRemoteFile(org.syncany.plugins.transfer.files.MultichunkRemoteFile) SyncanyRemoteFile(org.syncany.plugins.transfer.files.SyncanyRemoteFile)

Aggregations

RemoteFile (org.syncany.plugins.transfer.files.RemoteFile)18 MultichunkRemoteFile (org.syncany.plugins.transfer.files.MultichunkRemoteFile)11 File (java.io.File)10 TempRemoteFile (org.syncany.plugins.transfer.files.TempRemoteFile)10 TransactionRemoteFile (org.syncany.plugins.transfer.files.TransactionRemoteFile)10 DatabaseRemoteFile (org.syncany.plugins.transfer.files.DatabaseRemoteFile)9 StorageException (org.syncany.plugins.transfer.StorageException)7 SyncanyRemoteFile (org.syncany.plugins.transfer.files.SyncanyRemoteFile)7 ActionRemoteFile (org.syncany.plugins.transfer.files.ActionRemoteFile)5 CleanupRemoteFile (org.syncany.plugins.transfer.files.CleanupRemoteFile)5 IOException (java.io.IOException)3 MasterRemoteFile (org.syncany.plugins.transfer.files.MasterRemoteFile)3 ActionTO (org.syncany.plugins.transfer.to.ActionTO)3 FilenameFilter (java.io.FilenameFilter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1 Test (org.junit.Test)1