protected File getAbsolutePathFile(String relativePath) { return new File(config.getLocalDir(), relativePath); // TODO [medium] This does not work for 'some\file' on windows! }
private void forceKillWatchThread() { try { logger.log(Level.INFO, "STOPPING WATCH " + config.getLocalDir() + " ..."); if (watchThread != null && !watchThread.isInterrupted()) { watchThread.interrupt(); } } catch (Exception e) { logger.log(Level.INFO, "Forcefully stopping watch thread FAILED at " + config.getLocalDir() + ". Giving up.", e); } }
@Override public void run() { try { logger.log(Level.INFO, "STOP GRACE PERIOD OVER. STOPPING WATCH " + config.getLocalDir() + " ..."); if (watchThread != null && !watchThread.isInterrupted()) { watchThread.interrupt(); } } catch (Exception e) { logger.log(Level.INFO, "Forcefully stopping watch thread FAILED at " + config.getLocalDir() + ". Giving up."); } } }, STOP_GRACE_PERIOD);
private void stopRecursiveWatcher() { try { logger.log(Level.INFO, "Stopping recursive watcher for " + config.getLocalDir() + " ..."); recursiveWatcher.stop(); } catch (Exception e) { logger.log(Level.WARNING, "Cannot stop file watcher.", e); } }
private List<File> extractLocallyDeletedFiles(ChangeSet localChanges) { List<File> locallyDeletedFiles = new ArrayList<File>(); for (String relativeFilePath : localChanges.getDeletedFiles()) { locallyDeletedFiles.add(new File(config.getLocalDir() + File.separator + relativeFilePath)); } return locallyDeletedFiles; }
private void stopNotificationListener() { logger.log(Level.INFO, "Stopping notification listener for " + config.getLocalDir() + " ..."); notificationListener.stop(); }
@Override public void onFinish() { eventBus.post(new UpIndexEndSyncExternalEvent(config.getLocalDir().getAbsolutePath())); }
private void fireEndEvent() { eventBus.post(new WatchEndSyncExternalEvent(config.getLocalDir().getAbsolutePath())); } }
private void fireHasChangesEvent() { boolean firstNewFileDetected = newDatabaseVersion.getFileHistories().size() == 1; if (firstNewFileDetected) { // Only fires once! eventBus.post(new UpIndexChangesDetectedSyncExternalEvent(config.getLocalDir().getAbsolutePath())); } }
public IndexerDeduperListener(DatabaseVersion newDatabaseVersion) { this.fileVersionComparator = new FileVersionComparator(config.getLocalDir(), config.getChunker().getChecksumAlgorithm()); this.secureRandom = new SecureRandom(); this.newDatabaseVersion = newDatabaseVersion; }
private NormalizedPath findTargetPath() throws Exception { NormalizedPath targetPath = null; if (relativeTargetPath == null) { String restoredSuffix = "restored version " + fileVersion2.getVersion(); targetPath = new NormalizedPath(config.getLocalDir(), fileVersion2.getPath()).withSuffix(restoredSuffix, false); } else { targetPath = new NormalizedPath(config.getLocalDir(), relativeTargetPath); } return targetPath; } }
/** * This method uploads a local copy of the transaction to the repository. This is done at the begin of commit() * and is the starting point of the transaction itself. */ private TransactionRemoteFile uploadTransactionFile(File localTransactionFile) throws StorageException { TransactionRemoteFile remoteTransactionFile = new TransactionRemoteFile(this); eventBus.post(new UpUploadFileSyncExternalEvent(config.getLocalDir().getAbsolutePath(), remoteTransactionFile.getName())); logger.log(Level.INFO, "- Uploading remote transaction file {0} ...", remoteTransactionFile); transferManager.upload(localTransactionFile, remoteTransactionFile); return remoteTransactionFile; }
public FileSystemAction(Config config, MemoryDatabase winningDatabase, FileVersion file1, FileVersion file2) { this.config = config; this.winningDatabase = winningDatabase; this.fileVersion1 = file1; this.fileVersion2 = file2; this.fileVersionHelper = new FileVersionComparator(config.getLocalDir(), config.getChunker().getChecksumAlgorithm()); }
private ChangeSet findLocalChanges(final Map<String, FileVersion> filesInDatabase) throws FileNotFoundException, IOException { ChangeSet localChanges = findLocalChangedAndNewFiles(config.getLocalDir(), filesInDatabase); if (options == null || options.isDelete()) { findAndAppendDeletedFiles(localChanges, filesInDatabase); } return localChanges; }
protected void moveToConflictFile(FileVersion targetFileVersion) throws IOException { NormalizedPath targetConflictingFile = new NormalizedPath(config.getLocalDir(), targetFileVersion.getPath()); moveToConflictFile(targetConflictingFile); }
private void startNotificationListener() { logger.log(Level.INFO, "Starting notification listener for " + config.getLocalDir() + " ..."); notificationListener = new NotificationListener(options.getAnnouncementsHost(), options.getAnnouncementsPort(), this); notificationListener.start(); notificationListener.subscribe(notificationChannel); }
public FileSystemActionReconciliator(Config config, ChangeSet changeSet) { this.config = config; this.changeSet = changeSet; this.localDatabase = new SqlDatabase(config); this.fileVersionComparator = new FileVersionComparator(config.getLocalDir(), config.getChunker().getChecksumAlgorithm()); }
public StatusOperation(Config config, StatusOperationOptions options) { super(config); this.fileVersionComparator = new FileVersionComparator(config.getLocalDir(), config.getChunker().getChecksumAlgorithm()); this.localDatabase = new SqlDatabase(config); this.options = options; this.eventBus = LocalEventBus.getInstance(); }
private void startIndexerThread(BlockingQueue<DatabaseVersion> databaseVersionQueue) { // Get a list of files that have been updated ChangeSet localChanges = result.getStatusResult().getChangeSet(); List<File> locallyUpdatedFiles = extractLocallyUpdatedFiles(localChanges); List<File> locallyDeletedFiles = extractLocallyDeletedFiles(localChanges); // Iterate over the changes, deduplicate, and feed DatabaseVersions into an iterator Deduper deduper = new Deduper(config.getChunker(), config.getMultiChunker(), config.getTransformer(), options.getTransactionSizeLimit(), options.getTransactionFileLimit()); AsyncIndexer asyncIndexer = new AsyncIndexer(config, deduper, locallyUpdatedFiles, locallyDeletedFiles, databaseVersionQueue); new Thread(asyncIndexer, "AsyncI/" + config.getLocalDir().getName()).start(); }
public static void deleteTestLocalConfigAndData(Config config) { TestFileUtil.deleteDirectory(config.getLocalDir()); TestFileUtil.deleteDirectory(config.getCacheDir()); TestFileUtil.deleteDirectory(config.getDatabaseDir()); if (config.getAppDir() != null) { TestFileUtil.deleteDirectory(config.getAppDir()); } // TODO [low] workaround: delete empty parent folder of getAppDir() --> ROOT/app/.. --> ROOT/ config.getLocalDir().getParentFile().delete(); // if empty! deleteTestLocalConnection(config); }