public override void Solve(
IFileSystemInfo localFileSystemInfo,
IObjectId remoteId,
ContentChangeType localContent = ContentChangeType.NONE,
ContentChangeType remoteContent = ContentChangeType.NONE)
{
if (localFileSystemInfo is IFileInfo && remoteId is IDocument) {
var localFile = localFileSystemInfo as IFileInfo;
var remoteDocument = remoteId as IDocument;
var mappedObject = this.Storage.GetObject(localFile);
if (mappedObject == null) {
throw new ArgumentException(string.Format("Could not find db entry for {0} => invoke crawl sync", localFileSystemInfo.FullName));
}
if (mappedObject.LastChangeToken != (remoteId as ICmisObjectProperties).ChangeToken) {
throw new ArgumentException(string.Format("remote {1} {0} has also been changed since last sync => invoke crawl sync", remoteId.Id, remoteId is IDocument ? "document" : "folder"));
}
if (localFile != null && localFile.IsContentChangedTo(mappedObject, scanOnlyIfModificationDateDiffers: true)) {
Logger.Debug(string.Format("\"{0}\" is different from {1}", localFile.FullName, mappedObject.ToString()));
OperationsLogger.Debug(string.Format("Local file \"{0}\" has been changed", localFile.FullName));
try {
var transmission = this.transmissionManager.CreateTransmission(TransmissionType.UPLOAD_MODIFIED_FILE, localFile.FullName);
mappedObject.LastChecksum = this.UploadFileWithPWC(localFile, ref remoteDocument, transmission);
mappedObject.ChecksumAlgorithmName = "SHA-1";
if (remoteDocument.Id != mappedObject.RemoteObjectId) {
this.TransmissionStorage.RemoveObjectByRemoteObjectId(mappedObject.RemoteObjectId);
mappedObject.RemoteObjectId = remoteDocument.Id;
}
} catch (Exception ex) {
if (ex.InnerException is CmisPermissionDeniedException) {
OperationsLogger.Warn(string.Format("Local changed file \"{0}\" has not been uploaded: PermissionDenied", localFile.FullName));
return;
} else if (ex.InnerException is CmisStorageException) {
OperationsLogger.Warn(string.Format("Local changed file \"{0}\" has not been uploaded: StorageException", localFile.FullName), ex);
return;
}
throw;
}
mappedObject.LastRemoteWriteTimeUtc = remoteDocument.LastModificationDate;
mappedObject.LastLocalWriteTimeUtc = localFile.LastWriteTimeUtc;
mappedObject.LastContentSize = localFile.Length;
OperationsLogger.Info(string.Format("Local changed file \"{0}\" has been uploaded", localFile.FullName));
}
mappedObject.LastChangeToken = remoteDocument.ChangeToken;
mappedObject.LastLocalWriteTimeUtc = localFile.LastWriteTimeUtc;
this.Storage.SaveMappedObject(mappedObject);
} else {
this.folderOrFileContentUnchangedSolver.Solve(localFileSystemInfo, remoteId, localContent, remoteContent);
}
return;
}
}