Skip to content

Commit 84e41bb

Browse files
committed
Fixed improper exception catching in permission check. Safe mode settings item added
1 parent 9c1afa1 commit 84e41bb

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

FreeMove/Form1.Designer.cs

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeMove/Form1.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private bool CheckFolders(string source, string destination)
175175
});
176176
});
177177
}
178-
catch(UnauthorizedAccessException ex)
178+
catch(Exception ex) when (ex is IOException || ex is UnauthorizedAccessException)
179179
{
180180
passing = false;
181181
errors += $"{ex.Message}\n";
@@ -189,7 +189,7 @@ void CheckFile(string file)
189189
{
190190
fs = fi.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
191191
}
192-
catch (IOException ex)
192+
catch (Exception ex) when (ex is IOException || ex is UnauthorizedAccessException)
193193
{
194194
passing = false;
195195
errors += $"{ex.Message}\n";
@@ -222,7 +222,7 @@ void CheckFile(string file)
222222

223223

224224
if (!passing)
225-
MessageBox.Show(errors, "Errors encounered during preliminary phase");
225+
MessageBox.Show(errors, "Errors encountered during preliminary phase");
226226

227227
return passing;
228228
}
@@ -416,5 +416,15 @@ private void FullPermissionCheckToolStripMenuItem_Click(object sender, EventArgs
416416
Settings.TogglePermCheck();
417417
PermissionCheckToolStripMenuItem.Checked = Settings.PermCheck;
418418
}
419+
420+
private void SafeModeToolStripMenuItem_Click(object sender, EventArgs e)
421+
{
422+
if (MessageBox.Show(Properties.Resources.DisableSafeModeMessage, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
423+
{
424+
safeMode = false;
425+
safeModeToolStripMenuItem.Checked = false;
426+
safeModeToolStripMenuItem.Enabled = false;
427+
}
428+
}
419429
}
420430
}

FreeMove/Properties/Resources.Designer.cs

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreeMove/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ This program is licensed under the GNU General Public License v3.0
124124
For more informations https://github.com/imDema/FreeMove/blob/master/LICENSE.txt
125125

126126
https://github.com/imDema</value>
127+
</data>
128+
<data name="DisableSafeModeMessage" xml:space="preserve">
129+
<value>It's strongly recommended not to move the "Program Files" or the "Program Files (x86)" directories as it can lead to unexpexted behaviour.
130+
You are free to move any of the programs contained in those directories without any problem instead.
131+
132+
Are you sure you want to disable safe mode?</value>
127133
</data>
128134
<data name="ErrorUnauthorizedLink" xml:space="preserve">
129135
<value>ERROR creating symbolic link.

0 commit comments

Comments
 (0)