Search in sources :

Example 1 with UpIndexMidSyncExternalEvent

use of org.syncany.operations.daemon.messages.UpIndexMidSyncExternalEvent 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.
    // }
    }
}
Also used : UpIndexMidSyncExternalEvent(org.syncany.operations.daemon.messages.UpIndexMidSyncExternalEvent) DatabaseVersion(org.syncany.database.DatabaseVersion) DeduperListener(org.syncany.chunk.DeduperListener)

Aggregations

DeduperListener (org.syncany.chunk.DeduperListener)1 DatabaseVersion (org.syncany.database.DatabaseVersion)1 UpIndexMidSyncExternalEvent (org.syncany.operations.daemon.messages.UpIndexMidSyncExternalEvent)1