New SQLite version
[pithos-ms-client] / trunk / Pithos.Core / Agents / WorkflowAgent.cs
index 5fe0cda..5ff697e 100644 (file)
@@ -139,6 +139,13 @@ namespace Pithos.Core.Agents
                                 NetworkAgent.Post(new CloudDeleteAction(accountInfo, info, fileState));
                                 break;
                             case FileStatus.Renamed:
+                                if (state.OldPath == null)
+                                {
+                                    //We reach this point only if the app closed before propagating a rename to the server
+                                    Log.WarnFormat("Unfinished rename [{0}]",state.Path);
+                                    StatusKeeper.SetFileState(state.Path,FileStatus.Conflict,FileOverlayStatus.Conflict, "Rename without old path");
+                                    break;
+                                }
                                 FileSystemInfo oldInfo = Directory.Exists(state.OldPath)
                                                              ? (FileSystemInfo) new DirectoryInfo(state.OldPath)
                                                              : new FileInfo(state.OldPath);
@@ -211,7 +218,7 @@ namespace Pithos.Core.Agents
         public void RestartInterruptedFiles(AccountInfo accountInfo)
         {
             
-
+            StatusKeeper.CleanupOrphanStates();
             using (log4net.ThreadContext.Stacks["Operation"].Push("RestartInterrupted"))
             {
                 if (Log.IsDebugEnabled)
@@ -226,6 +233,8 @@ namespace Pithos.Core.Agents
                 var account = accountInfo;
                 var pendingEntries = (from state in FileState.Queryable
                                      where state.FileStatus != FileStatus.Unchanged &&
+                                            state.FileStatus != FileStatus.Forbidden &&
+                                            state.FileStatus != FileStatus.Conflict &&
                                            !state.FilePath.StartsWith(cachePath) &&
                                            !state.FilePath.EndsWith(".ignore") &&
                                            state.FilePath.StartsWith(account.AccountPath)