1
0
Эх сурвалжийг харах

Bug 1506: Do not abort "Keep remote directory up to date" when "Continue on error" (or "option batch continue") is enabled and reading a local directory fails, because it was deleted

https://winscp.net/tracker/1506

Source commit: 1e5c594bd8517725bc54e94ef989efc359ece21a
Martin Prikryl 8 жил өмнө
parent
commit
c48014729d

+ 10 - 2
source/forms/CustomScpExplorer.cpp

@@ -4962,8 +4962,16 @@ void __fastcall TCustomScpExplorerForm::DoSynchronize(
     }
     catch (Exception & E)
     {
-      ShowExtendedExceptionEx(Terminal, &E);
-      throw;
+      if (FLAGSET(Params.Options, soContinueOnError) && Terminal->Active &&
+          DebugAlwaysTrue(FOnFeedSynchronizeError != NULL))
+      {
+        // noop, already logged in MoreMessageDialog
+      }
+      else
+      {
+        ShowExtendedExceptionEx(Terminal, &E);
+        throw;
+      }
     }
   }
 }

+ 14 - 7
source/packages/my/DiscMon.pas

@@ -574,15 +574,22 @@ var
     // Notification signalled, so fire the OnChange event and then FindNext..
     // loop back to re-WaitFor... the thread
     Sleep(FChangeDelay);
-    FNotifiedDirectory := FDirectories[Directory];
-    FSubdirsChanged := False;
+    Result := WAIT_TIMEOUT;
+    // When deleting a tree, we may get notification about change in the directory
+    // before notification about deleting the directory.
+    // While this does not 100% protect against an attempt to synchronize the deleted directory,
+    // it may greatly reduce the risk (as checked after the sleep above).
+    // Though actually it's may not even be possible to delete the directory as we have it locked.
+    if DirectoryExists(FDirectories[Directory]) then
+    begin
+      FNotifiedDirectory := FDirectories[Directory];
+      FSubdirsChanged := False;
 
-    DoSynchronize(InformChange);
+      DoSynchronize(InformChange);
 
-    if FSubdirsChanged then
-      Result := UpdateSubDirectories(Directory)
-    else
-      Result := WAIT_TIMEOUT;
+      if FSubdirsChanged then
+        Result := UpdateSubDirectories(Directory)
+    end;
 
     FindNextChangeNotification(Handle);
   end;

+ 17 - 2
source/windows/ConsoleRunner.cpp

@@ -1728,8 +1728,23 @@ void __fastcall TConsoleRunner::SynchronizeControllerSynchronize(
 {
   if (!Full)
   {
-    FScript->Synchronize(LocalDirectory, RemoteDirectory, CopyParam,
-      Params.Params, Checklist);
+    try
+    {
+      FScript->Synchronize(LocalDirectory, RemoteDirectory, CopyParam,
+        Params.Params, Checklist);
+    }
+    catch (Exception & E)
+    {
+      if ((FScript->Batch == TScript::BatchContinue) &&
+          FScript->Terminal->Active)
+      {
+        // noop
+      }
+      else
+      {
+        throw;
+      }
+    }
   }
 }
 //---------------------------------------------------------------------------