Search in sources :

Example 11 with FileSnapshot

use of org.jumpmind.symmetric.model.FileSnapshot in project symmetric-ds by JumpMind.

the class FileSyncService method saveDirectorySnapshot.

protected long saveDirectorySnapshot(FileTriggerRouter fileTriggerRouter, DirectorySnapshot dirSnapshot) {
    long totalBytes = 0;
    for (FileSnapshot fileSnapshot : dirSnapshot) {
        File file = fileTriggerRouter.getFileTrigger().createSourceFile(fileSnapshot);
        String filePath = file.getParentFile().getPath().replace('\\', '/');
        String fileName = file.getName();
        String nodeId = null;
        if (engine.getParameterService().is(ParameterConstants.FILE_SYNC_PREVENT_PING_BACK)) {
            nodeId = findSourceNodeIdFromFileIncoming(filePath, fileName, fileSnapshot.getFileModifiedTime());
        }
        if (StringUtils.isNotBlank(nodeId)) {
            fileSnapshot.setLastUpdateBy(nodeId);
        } else {
            fileSnapshot.setLastUpdateBy(null);
        }
        log.debug("Captured change " + fileSnapshot);
        totalBytes += fileSnapshot.getFileSize();
    }
    save(dirSnapshot);
    return totalBytes;
}
Also used : FileSnapshot(org.jumpmind.symmetric.model.FileSnapshot) File(java.io.File)

Aggregations

FileSnapshot (org.jumpmind.symmetric.model.FileSnapshot)11 FileTriggerRouter (org.jumpmind.symmetric.model.FileTriggerRouter)5 File (java.io.File)4 FileTrigger (org.jumpmind.symmetric.model.FileTrigger)4 ArrayList (java.util.ArrayList)3 Table (org.jumpmind.db.model.Table)2 CsvData (org.jumpmind.symmetric.io.data.CsvData)2 Data (org.jumpmind.symmetric.model.Data)2 EvalError (bsh.EvalError)1 TargetError (bsh.TargetError)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 ZipEntry (java.util.zip.ZipEntry)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)1 IoException (org.jumpmind.exception.IoException)1 DataEventType (org.jumpmind.symmetric.io.data.DataEventType)1