Search in sources :

Example 1 with CleanupRemoteFile

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

the class CleanupOperation method updateCleanupFileInTransaction.

/**
	 * This method checks what the current cleanup number is, increments it by one and adds
	 * a new cleanup file to the transaction, to signify to other clients that Cleanup has occurred.
	 */
private void updateCleanupFileInTransaction() throws StorageException, IOException {
    if (remoteTransaction.isEmpty()) {
        // No need to bump numbers
        return;
    }
    // Find all existing cleanup files
    Map<String, CleanupRemoteFile> cleanupFiles = transferManager.list(CleanupRemoteFile.class);
    long lastRemoteCleanupNumber = getLastRemoteCleanupNumber(cleanupFiles);
    // Schedule any existing cleanup files for deletion
    for (CleanupRemoteFile cleanupRemoteFile : cleanupFiles.values()) {
        remoteTransaction.delete(cleanupRemoteFile);
    }
    // Upload a new cleanup file that indicates changes
    File newCleanupFile = config.getCache().createTempFile("cleanup");
    long newCleanupNumber = lastRemoteCleanupNumber + 1;
    remoteTransaction.upload(newCleanupFile, new CleanupRemoteFile(newCleanupNumber));
    localDatabase.writeCleanupNumber(newCleanupNumber);
}
Also used : CleanupRemoteFile(org.syncany.plugins.transfer.files.CleanupRemoteFile) RemoteFile(org.syncany.plugins.transfer.files.RemoteFile) DatabaseRemoteFile(org.syncany.plugins.transfer.files.DatabaseRemoteFile) CleanupRemoteFile(org.syncany.plugins.transfer.files.CleanupRemoteFile) File(java.io.File) MultichunkRemoteFile(org.syncany.plugins.transfer.files.MultichunkRemoteFile)

Aggregations

File (java.io.File)1 CleanupRemoteFile (org.syncany.plugins.transfer.files.CleanupRemoteFile)1 DatabaseRemoteFile (org.syncany.plugins.transfer.files.DatabaseRemoteFile)1 MultichunkRemoteFile (org.syncany.plugins.transfer.files.MultichunkRemoteFile)1 RemoteFile (org.syncany.plugins.transfer.files.RemoteFile)1