Browse Source

Bug 1616: Do not show an error when remembered last used directories do not exist anymore

https://winscp.net/tracker/1616

Source commit: 941569e52a6dce82e927cced2120521bb24ea816
Martin Prikryl 7 years ago
parent
commit
7bb4462178
2 changed files with 25 additions and 2 deletions
  1. 21 1
      source/core/Terminal.cpp
  2. 4 1
      source/forms/ScpCommander.cpp

+ 21 - 1
source/core/Terminal.cpp

@@ -3203,7 +3203,27 @@ void __fastcall TTerminal::DoStartup()
 
     if (!SessionData->RemoteDirectory.IsEmpty())
     {
-      ChangeDirectory(SessionData->RemoteDirectory);
+      if (SessionData->UpdateDirectories)
+      {
+        ExceptionOnFail = true;
+        try
+        {
+          ChangeDirectory(SessionData->RemoteDirectory);
+        }
+        catch (...)
+        {
+          if (!Active)
+          {
+            LogEvent(L"Configured initial remote directory cannot be opened, staying in the home directory.");
+            throw;
+          }
+        }
+        ExceptionOnFail = false;
+      }
+      else
+      {
+        ChangeDirectory(SessionData->RemoteDirectory);
+      }
     }
   }
   __finally

+ 4 - 1
source/forms/ScpCommander.cpp

@@ -492,7 +492,10 @@ void __fastcall TScpCommanderForm::TerminalChanged()
         catch(Exception & E)
         {
           DocumentsDir = true;
-          Terminal->ShowExtendedException(&E);
+          if (!Terminal->SessionData->UpdateDirectories)
+          {
+            Terminal->ShowExtendedException(&E);
+          }
         }
       }