{
var client = new CloudFilesClient(accountInfo);
+
//Even if GetObjectInfo times out, we can proceed with the upload
var cloudInfo = client.GetObjectInfo(account, cloudFile.Container, cloudFile.Name);
- //If this is a read-only file, do not upload changes
- if (!cloudInfo.IsWritable(action.AccountInfo.UserName))
- return;
+ //If this a shared file
+ if (!cloudFile.Account.Equals(action.AccountInfo.UserName,StringComparison.InvariantCultureIgnoreCase))
+ {
+ //If this is a read-only file, do not upload changes
+ if (!cloudInfo.IsWritable(action.AccountInfo.UserName))
+ {
+ MakeFileReadOnly(fullFileName);
+ return;
+ }
- //TODO: If the object does not exist, check that we can upload to the folder
+ //If the file is new, can we upload it?
+ if ( !cloudInfo.Exists && !client.CanUpload(account, cloudFile))
+ {
+ MakeFileReadOnly(fullFileName);
+ return;
+ }
+
+ }
if (fileInfo is DirectoryInfo)
{
if (response.StatusCode == HttpStatusCode.Forbidden)
{
StatusKeeper.SetFileState(fileInfo.FullName, FileStatus.Forbidden, FileOverlayStatus.Conflict, "Forbidden");
-
+ MakeFileReadOnly(fullFileName);
}
else
//In any other case, propagate the error
}
}
+ private static void MakeFileReadOnly(string fullFileName)
+ {
+ var attributes = File.GetAttributes(fullFileName);
+ //Do not make any modifications if not necessary
+ if (attributes.HasFlag(FileAttributes.ReadOnly))
+ return;
+ File.SetAttributes(fullFileName, attributes | FileAttributes.ReadOnly);
+ }
+
private static AccountInfo GetSharerAccount(string relativePath, AccountInfo accountInfo)
{
var parts = relativePath.Split('\\');