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);
}
Aggregations