public override void Solve(
IFileSystemInfo localFile,
IObjectId remoteId,
ContentChangeType localContent = ContentChangeType.NONE,
ContentChangeType remoteContent = ContentChangeType.NONE)
{
IMappedObject obj = this.Storage.GetObjectByRemoteId(remoteId.Id);
if (remoteId is IFolder) {
var remoteFolder = remoteId as IFolder;
DateTime? lastModified = remoteFolder.LastModificationDate;
obj.LastChangeToken = remoteFolder.ChangeToken;
if (lastModified != null) {
try {
localFile.LastWriteTimeUtc = (DateTime)lastModified;
} catch(IOException e) {
Logger.Debug("Couldn't set the server side modification date", e);
}
obj.Ignored = remoteFolder.AreAllChildrenIgnored();
obj.LastLocalWriteTimeUtc = localFile.LastWriteTimeUtc;
}
} else if (remoteId is IDocument) {
var remoteDocument = remoteId as IDocument;
DateTime? lastModified = remoteDocument.LastModificationDate;
if ((lastModified != null && lastModified != obj.LastRemoteWriteTimeUtc) || obj.LastChangeToken != remoteDocument.ChangeToken) {
if (remoteContent != ContentChangeType.NONE) {
if (obj.LastLocalWriteTimeUtc != localFile.LastWriteTimeUtc) {
throw new ArgumentException("The local file has been changed since last write => aborting update");
}
obj.LastChecksum = DownloadChanges(localFile as IFileInfo, remoteDocument, obj, this.fsFactory, this.transmissonManager, Logger);
}
obj.LastRemoteWriteTimeUtc = remoteDocument.LastModificationDate;
if (remoteDocument.LastModificationDate != null) {
localFile.LastWriteTimeUtc = (DateTime)remoteDocument.LastModificationDate;
}
obj.LastLocalWriteTimeUtc = localFile.LastWriteTimeUtc;
obj.LastContentSize = remoteDocument.ContentStreamLength ?? 0;
}
obj.LastChangeToken = remoteDocument.ChangeToken;
obj.LastRemoteWriteTimeUtc = lastModified;
}
this.Storage.SaveMappedObject(obj);
}
}