public static SyncFile renameFileSyncFile(Path filePath, long syncAccountId, SyncFile syncFile) throws Exception { // Local sync file String name = _getName(filePath, syncFile); String sourceFileName = syncFile.getName(); long sourceVersionId = syncFile.getVersionId(); syncFile.setFilePathName(filePath.toString()); syncFile.setName(name); update(syncFile); // Remote sync file if ((syncFile.getState() != SyncFile.STATE_ERROR) && (syncFile.getState() != SyncFile.STATE_UNSYNCED)) { FileEventUtil.updateFile( filePath, syncAccountId, syncFile, null, name, syncFile.getChecksum(), sourceFileName, sourceVersionId, syncFile.getChecksum()); } return syncFile; }
public static SyncFile updateFileSyncFile(Path filePath, long syncAccountId, SyncFile syncFile) throws Exception { // Local sync file if (FileUtil.getFileKey(filePath) != syncFile.getSyncFileId()) { FileUtil.writeFileKey(filePath, String.valueOf(syncFile.getSyncFileId())); } Path deltaFilePath = null; String name = _getName(filePath, syncFile); String sourceChecksum = syncFile.getChecksum(); String sourceFileName = syncFile.getName(); long sourceVersionId = syncFile.getVersionId(); String targetChecksum = FileUtil.getChecksum(filePath); if (!FileUtil.checksumsEqual(sourceChecksum, targetChecksum) && !IODeltaUtil.isIgnoredFilePatchingExtension(syncFile)) { deltaFilePath = Files.createTempFile(String.valueOf(filePath.getFileName()), ".tmp"); deltaFilePath = IODeltaUtil.delta(filePath, IODeltaUtil.getChecksumsFilePath(syncFile), deltaFilePath); IODeltaUtil.checksums(syncFile); } syncFile.setChecksum(targetChecksum); syncFile.setFilePathName(filePath.toString()); syncFile.setName(name); update(syncFile); // Remote sync file if ((syncFile.getState() != SyncFile.STATE_ERROR) && (syncFile.getState() != SyncFile.STATE_UNSYNCED)) { FileEventUtil.updateFile( filePath, syncAccountId, syncFile, deltaFilePath, name, sourceChecksum, sourceFileName, sourceVersionId, targetChecksum); } return syncFile; }