private bool UpdateFile(string filePath, IFolder remoteFolder)
{
SleepWhileSuspended();
try
{
// Find the document within the folder.
var syncItem = database.GetSyncItemFromLocalPath(filePath);
if (null == syncItem)
{
syncItem = SyncItemFactory.CreateFromLocalPath(filePath, false, repoInfo, database);
}
string fileName = syncItem.RemoteLeafname;
IDocument document = null;
bool found = false;
foreach (ICmisObject obj in remoteFolder.GetChildren())
{
if (null != (document = obj as IDocument))
{
if (repoInfo.CmisProfile.localFilename(document).Equals(fileName))
{
found = true;
break;
}
}
}
// If not found, it means the document has been deleted.
if (!found)
{
Logger.Info(syncItem.LocalPath + " not found on server, must be uploaded instead of updated");
return UploadFile(syncItem.LocalPath, remoteFolder);
}
// Update the document itself.
return UpdateFile(syncItem.LocalPath, document);
}
catch (CmisBaseException e)
{
ProcessRecoverableException("Could not update file: " + filePath, e);
return false;
}
}