X-Git-Url: https://code.grnet.gr/git/pithos-ms-client/blobdiff_plain/026a6c5a44761d3274a6eab3fa44bb7e3f1d54ff..2341c6036d5af50def10d2696063955ce199360d:/trunk/Pithos.Core/Agents/StatusAgent.cs diff --git a/trunk/Pithos.Core/Agents/StatusAgent.cs b/trunk/Pithos.Core/Agents/StatusAgent.cs index 032af01..7090f90 100644 --- a/trunk/Pithos.Core/Agents/StatusAgent.cs +++ b/trunk/Pithos.Core/Agents/StatusAgent.cs @@ -346,6 +346,12 @@ namespace Pithos.Core.Agents command.Parameters.AddWithValue("path", path); var affected = command.ExecuteNonQuery(); + if (affected == 0) + { + var createdState = FileState.CreateFor(FileInfoExtensions.FromPath(path)); + createdState.FileStatus = status; + createdState.Create(); + } return affected; } } @@ -357,7 +363,7 @@ namespace Pithos.Core.Agents } } - private int UpdateStatusDirect(string absolutePath, FileStatus fileStatus, FileOverlayStatus overlayStatus) + private int UpdateStatusDirect(string absolutePath, FileStatus fileStatus, FileOverlayStatus overlayStatus, string conflictReason) { using (log4net.ThreadContext.Stacks["StatusAgent"].Push("UpdateStatusDirect")) { @@ -370,15 +376,24 @@ namespace Pithos.Core.Agents using ( var command = new SQLiteCommand( - "update FileState set OverlayStatus= :overlayStatus, FileStatus= :fileStatus where FilePath = :path COLLATE NOCASE ", + "update FileState set OverlayStatus= :overlayStatus, FileStatus= :fileStatus,ConflictReason= :conflictReason where FilePath = :path COLLATE NOCASE ", connection)) { command.Parameters.AddWithValue("path", absolutePath); command.Parameters.AddWithValue("fileStatus", fileStatus); command.Parameters.AddWithValue("overlayStatus", overlayStatus); + command.Parameters.AddWithValue("conflictReason", conflictReason); var affected = command.ExecuteNonQuery(); + if (affected == 0) + { + var createdState=FileState.CreateFor(FileInfoExtensions.FromPath(absolutePath)); + createdState.FileStatus = fileStatus; + createdState.OverlayStatus = overlayStatus; + createdState.ConflictReason = conflictReason; + createdState.Create(); + } return affected; } } @@ -569,7 +584,7 @@ namespace Pithos.Core.Agents _persistenceAgent.Post(() =>FileState.RenameState(oldPath, newPath)); }*/ - public void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus) + public void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus, string conflictReason) { if (String.IsNullOrWhiteSpace(path)) throw new ArgumentNullException("path"); @@ -580,7 +595,7 @@ namespace Pithos.Core.Agents Debug.Assert(!path.Contains(FolderConstants.CacheFolder)); Debug.Assert(!path.EndsWith(".ignore")); - _persistenceAgent.Post(() => UpdateStatusDirect(path, fileStatus, overlayStatus)); + _persistenceAgent.Post(() => UpdateStatusDirect(path, fileStatus, overlayStatus, conflictReason)); } /* @@ -874,7 +889,7 @@ namespace Pithos.Core.Agents //Stale states are those that have no corresponding local or server file - return; + var agent=FileAgent.GetFileAgent(accountInfo); @@ -885,6 +900,7 @@ namespace Pithos.Core.Agents //infos of accounts, containers which have no Name var serverFiles = from info in objectInfos + where info.Name != null select Path.Combine(accountInfo.AccountPath,info.RelativeUrlToFilePath(accountInfo.UserName)); var serverSet = new HashSet(serverFiles);