Skip to content

Commit cac388a

Browse files
committed
Automatic merge of T1.5.1-1284-gca636331f4 and 13 pull requests
- Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #891 at 9a1d6b2: Auto save - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #952 at 8347095: Investigation - Pulsing graphics - Pull request #953 at a519452: Fix Lights Crash on Corrupt Shapes - Pull request #954 at 62061b8: Multiple Track Profiles & Superelevation Improvements - Pull request #972 at e90a2aa: On Map window color changed switch or signal is not changed - Pull request #980 at ba441dc: Downloading route content (Github, zip) second part - Pull request #981 at 10d297f: Multiple type trainset lightglows - Pull request #982 at efcf19c: WEB based Switch Panel enhancement: Alerter - Pull request #984 at 0f8122e: Player train switching for timetable mode - Pull request #900 at c27f32d: DMI updates - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder
15 parents cfc9cb3 + ca63633 + d00beb9 + 9a1d6b2 + 1f5ba4c + 8347095 + a519452 + 62061b8 + e90a2aa + ba441dc + 10d297f + efcf19c + 0f8122e + c27f32d + f92de76 commit cac388a

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

Source/Menu/ContentForm.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public partial class ContentForm : Form
5252
//attribute used to refresh UI
5353
private readonly SynchronizationContext AutoInstallSynchronizationContext;
5454

55+
public bool AutoInstallDoingTheSumOfTheFileBytes = false;
56+
5557
private readonly string ManualInstallBrouwseDir;
5658

5759
private bool In_dataGridViewManualInstall_SelectionChanged = false;
@@ -952,15 +954,17 @@ private void deleteRoute(string directoryInstalledIn)
952954
{
953955
Thread deleteThread = new Thread(() =>
954956
{
955-
ContentRouteSettings.directoryDelete(directoryInstalledIn);
957+
ContentRouteSettings.directoryDelete(directoryInstalledIn, ref AutoInstallDoingTheSumOfTheFileBytes);
956958
});
957959
// start delete in thread to be able to show the progress in the main thread
958960
deleteThread.Start();
959961

960962
while (deleteThread.IsAlive)
961963
{
962-
Stopwatch sw = Stopwatch.StartNew();
964+
// this will stop the delete until the sum is done
965+
AutoInstallDoingTheSumOfTheFileBytes = true;
963966

967+
Stopwatch sw = Stopwatch.StartNew();
964968
TotalBytes = 0;
965969
if (sumMB(directoryInstalledIn))
966970
{
@@ -970,6 +974,9 @@ private void deleteRoute(string directoryInstalledIn)
970974
string.Format("Left: {0} kB", (string)o);
971975
}), (TotalBytes / 1024).ToString("N0"));
972976
}
977+
978+
AutoInstallDoingTheSumOfTheFileBytes = false;
979+
973980
while (deleteThread.IsAlive && (sw.ElapsedMilliseconds <= 1000)) { }
974981
}
975982
}

Source/ORTS.Settings/ContentRouteSettings.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ public void LoadContent()
196196
}
197197
}
198198

199-
directoryDelete(definedContentJsonDirectoryName);
199+
bool doingTheSumOfTheFileBytes = false;
200+
directoryDelete(definedContentJsonDirectoryName, ref doingTheSumOfTheFileBytes);
200201
}
201202
catch (Exception error)
202203
{
@@ -250,29 +251,37 @@ private string convertResultToString(JToken result, string fieldName)
250251
}
251252
}
252253

253-
public static void directoryDelete(string directoryName)
254+
public static void directoryDelete(string directoryName, ref bool doingTheSumOfTheFileBytes)
254255
{
255256
if (Directory.Exists(directoryName))
256257
{
257258
// remove the read only flags,
258259
// otherwise the Directory.delete does not work in case read only files exists
259-
directoryRemoveReadOnlyFlags(directoryName);
260+
directoryRemoveReadOnlyFlagsAndDeleteFile(directoryName, ref doingTheSumOfTheFileBytes);
260261
Directory.Delete(directoryName, true);
261262
}
262263
}
263264

264-
private static void directoryRemoveReadOnlyFlags(string directoryName)
265+
private static void directoryRemoveReadOnlyFlagsAndDeleteFile(string directoryName, ref bool doingTheSumOfTheFileBytes)
265266
{
266267
foreach (string filename in Directory.GetFiles(directoryName))
267268
{
269+
while (doingTheSumOfTheFileBytes)
270+
{
271+
// stop deleteing file while summing in progress,
272+
// sum is for feedback to the user
273+
System.Threading.Thread.Sleep(10);
274+
}
275+
268276
_ = new FileInfo(filename)
269277
{
270278
IsReadOnly = false
271279
};
280+
File.Delete(filename);
272281
}
273282
foreach (string subDirectoryName in Directory.GetDirectories(directoryName))
274283
{
275-
directoryRemoveReadOnlyFlags(subDirectoryName);
284+
directoryRemoveReadOnlyFlagsAndDeleteFile(subDirectoryName, ref doingTheSumOfTheFileBytes);
276285
}
277286
}
278287
}

0 commit comments

Comments
 (0)