Revision 70f12b36 trunk/Pithos.Core/Agents/CloudTransferAction.cs

b/trunk/Pithos.Core/Agents/CloudTransferAction.cs
81 81
        {
82 82
            return String.Format("{0}:{1}->{2}", this.Action, this.LocalFile.FullName, this.CloudFile.Name);
83 83
        }
84

  
85
        protected static ObjectInfo CreateObjectInfoFor(AccountInfo accountInfo, FileSystemInfo fileInfo)
86
        {
87
            Contract.Requires(accountInfo!=null);
88
            Contract.Requires(fileInfo!=null);
89
            Contract.Ensures(Contract.Result<ObjectInfo>()!=null);
90

  
91
            var capitalizedFileInfo = fileInfo.WithProperCapitalization();
92
            var fullLocalName = capitalizedFileInfo.FullName;
93
            var othersPath = Path.Combine(accountInfo.AccountPath, FolderConstants.OthersFolder);
94
            
95
            var isShared = fullLocalName.StartsWith(othersPath, StringComparison.InvariantCultureIgnoreCase);
96
            if (isShared)
97
            {                
98
                var pathRelativeToOther = fullLocalName.Substring(othersPath.Length + 1);
99
                var otherParts = pathRelativeToOther.Split('\\');
100
                var otherName = otherParts[0];
101
                var otherContainer = otherParts[1];
102
                return new ObjectInfo
103
                           {
104
                               Account = otherName, 
105
                               Container = otherContainer, 
106
                               Name = String.Join("/", otherParts.Splice(2))
107
                           };
108
            }
109
            return new ObjectInfo(accountInfo.AccountPath, accountInfo.UserName, fileInfo);
110
        }
84 111
    }    
85 112

  
86 113
    public class CloudDownloadAction:CloudAction
......
110 137
    public class CloudDeleteAction:CloudAction
111 138
    {
112 139
        public CloudDeleteAction(AccountInfo accountInfo,FileSystemInfo fileInfo, FileState fileState)
113
            : this(accountInfo,fileInfo,new ObjectInfo(accountInfo.AccountPath,accountInfo.UserName,fileInfo.WithProperCapitalization()),fileState)
140
            : this(accountInfo,fileInfo,CreateObjectInfoFor(accountInfo, fileInfo),fileState)
114 141
        {            
115 142
        }
116 143

  
......
142 169
    public class CloudUploadAction:CloudAction
143 170
    {
144 171
        public CloudUploadAction(AccountInfo accountInfo, FileSystemInfo fileInfo, FileState state, int blockSize, string algorithm)
145
            : base(accountInfo, CloudActionType.UploadUnconditional, fileInfo, 
146
            new ObjectInfo(accountInfo.AccountPath, accountInfo.UserName,fileInfo), state, blockSize, algorithm)
172
            : base(accountInfo, CloudActionType.UploadUnconditional,fileInfo,CreateObjectInfoFor(accountInfo,fileInfo),state,blockSize,algorithm)             
147 173
        {
148 174
        }
149 175

  
......
165 191
            :base(accountInfo,action)
166 192
        {
167 193
            LocalFile = newFile;
168
            CloudFile = new ObjectInfo(accountInfo.AccountPath, accountInfo.UserName, newFile);
194
            CloudFile = CreateObjectInfoFor(accountInfo, newFile);
169 195
            
170 196
            OldLocalFile = oldFile;
171
            OldCloudFile = new ObjectInfo(accountInfo.AccountPath, accountInfo.UserName, oldFile);
197
            OldCloudFile = CreateObjectInfoFor(accountInfo, oldFile);
172 198

  
173 199
            //This is a rename operation, a hash will not be used
174 200
            LocalHash = new Lazy<string>(() => String.Empty, LazyThreadSafetyMode.ExecutionAndPublication);

Also available in: Unified diff