use of org.syncany.database.DatabaseVersion in project syncany by syncany.
the class DownOperation method applyChangesAndPersistDatabase.
private void applyChangesAndPersistDatabase(MemoryDatabase winnersDatabase, boolean cleanupOccurred, List<PartialFileHistory> preDeleteFileHistoriesWithLastVersion) throws Exception {
if (options.isApplyChanges()) {
new ApplyChangesOperation(config, localDatabase, transferManager, winnersDatabase, result, cleanupOccurred, preDeleteFileHistoriesWithLastVersion).execute();
} else {
logger.log(Level.INFO, "Doing nothing on the file system, because --no-apply switched on");
}
// We only persist the versions that we have already applied.
DatabaseBranch currentApplyBranch = new DatabaseBranch();
for (DatabaseVersion databaseVersion : winnersDatabase.getDatabaseVersions()) {
currentApplyBranch.add(databaseVersion.getHeader());
}
persistDatabaseVersions(currentApplyBranch, winnersDatabase);
localDatabase.commit();
}
use of org.syncany.database.DatabaseVersion in project syncany by syncany.
the class TestDatabaseUtil method createDatabaseVersion.
public static DatabaseVersion createDatabaseVersion(DatabaseVersionHeader basedOnDatabaseVersionHeader, Date date) {
VectorClock vectorClock = (basedOnDatabaseVersionHeader != null) ? basedOnDatabaseVersionHeader.getVectorClock().clone() : new VectorClock();
vectorClock.incrementClock("someclient");
DatabaseVersion databaseVersion = new DatabaseVersion();
databaseVersion.setClient("someclient");
databaseVersion.setTimestamp(date);
databaseVersion.setVectorClock(vectorClock);
return databaseVersion;
}
use of org.syncany.database.DatabaseVersion in project syncany by syncany.
the class Indexer method indexWithoutNewFiles.
private void indexWithoutNewFiles(List<File> files, List<File> deletedFiles, Queue<DatabaseVersion> databaseVersionQueue) {
DatabaseVersion newDatabaseVersion = new DatabaseVersion();
removeDeletedFiles(newDatabaseVersion, deletedFiles);
logger.log(Level.FINE, "Added database version with only deletions: " + newDatabaseVersion);
databaseVersionQueue.offer(newDatabaseVersion);
}
use of org.syncany.database.DatabaseVersion in project syncany by syncany.
the class Indexer method indexWithNewFiles.
private void indexWithNewFiles(List<File> files, List<File> deletedFiles, Queue<DatabaseVersion> databaseVersionQueue) throws IOException {
boolean isFirstFile = true;
int filesCount = files.size();
while (!files.isEmpty()) {
DatabaseVersion newDatabaseVersion = new DatabaseVersion();
// Create the DeduperListener that will receive MultiChunks and store them in the DatabaseVersion object
DeduperListener deduperListener = new IndexerDeduperListener(newDatabaseVersion);
// Signal the start of indexing if we are about to deduplicate the first file
if (isFirstFile) {
deduperListener.onStart(files.size());
// Add deletions in first database version
removeDeletedFiles(newDatabaseVersion, deletedFiles);
isFirstFile = false;
}
// Find and index new files
deduper.deduplicate(files, deduperListener);
if (!newDatabaseVersion.getFileHistories().isEmpty()) {
logger.log(Level.FINE, "Processed new database version: " + newDatabaseVersion);
databaseVersionQueue.offer(newDatabaseVersion);
int remainingFilesCount = filesCount - files.size();
eventBus.post(new UpIndexMidSyncExternalEvent(config.getLocalDir().toString(), filesCount, remainingFilesCount));
}
// else { (comment-only else case)
// Just chunks and multichunks, no filehistory. Since this means the file was being
// written/vanished during operations, it makes no sense to upload it. If the user
// wants it indexed, Up can be run again.
// }
}
}
use of org.syncany.database.DatabaseVersion in project syncany by syncany.
the class LogOperation method execute.
@Override
public LogOperationResult execute() throws Exception {
logger.log(Level.INFO, "");
logger.log(Level.INFO, "Running 'Log' at client " + config.getMachineName() + " ...");
logger.log(Level.INFO, "--------------------------------------------");
ArrayList<LightweightDatabaseVersion> databaseVersions = new ArrayList<>();
Iterator<DatabaseVersion> databaseVersionsIterator = localDatabase.getLastDatabaseVersions(options.getMaxDatabaseVersionCount(), options.getStartDatabaseVersionIndex(), options.getMaxFileHistoryCount());
while (databaseVersionsIterator.hasNext()) {
DatabaseVersion databaseVersion = databaseVersionsIterator.next();
LightweightDatabaseVersion lightweightDatabaseVersion = createLightweightDatabaseVersion(databaseVersion);
databaseVersions.add(lightweightDatabaseVersion);
}
return new LogOperationResult(databaseVersions);
}
Aggregations