Skip to content

Commit

Permalink
Patch release [v1.0.2.0]
Browse files Browse the repository at this point in the history
- Improved the auto update code
  • Loading branch information
o7q committed Jul 28, 2023
1 parent 98492ee commit 7a60b75
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
~ v1.0.2.0
- Improved the auto update code

~ v1.0.1.0
- Fixed bug with auto update not working
2 changes: 1 addition & 1 deletion src/Scribe/Scribe/Includes/Data/Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
public static class Constants
{
public const string VERSION = "v1.0.1";
public const string VERSION = "v1.0.2";
}
}
4 changes: 2 additions & 2 deletions src/Scribe/Scribe/Includes/Tools/Files.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public static int CleanFolder(string folder)
{
string extension = Path.GetExtension(filePath);

// Check if the current file is not the specified file type
// check if the current file is not the specified file type
if (extension != fileExtensionToKeep)
{
// Delete the file
// delete the file
try
{
File.Delete(filePath);
Expand Down
33 changes: 13 additions & 20 deletions src/Scribe/Scribe/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ private void MainMenu_Load(object sender, EventArgs e)

// configure and start mediaRefreshTimer
mediaRefreshTimer.Elapsed += new ElapsedEventHandler(MediaRefresh);
UpdateMediaRefreshTimer(60);
mediaRefreshTimer.Interval = 60 * 1000;
mediaRefreshTimer.Enabled = true;

CustomRenderer renderer = new CustomRenderer();
MainMenuContextMenuStrip.Renderer = renderer;
Expand Down Expand Up @@ -151,25 +152,18 @@ private void MainToolTip_Draw(object sender, DrawToolTipEventArgs e)
private void MediaRefresh(object source, ElapsedEventArgs e)
{
if (config.PROCESS_AUTO_UPDATE)
ProcessMedia();
}

private void UpdateMediaRefreshTimer(int time)
{
mediaRefreshTimer.Enabled = false;
mediaRefreshTimer.Interval = time * 1000;
mediaRefreshTimer.Enabled = true;
ProcessMedia(true);
}

private void ProcessMedia()
private void ProcessMedia(bool autoStart)
{
mediaRefreshTimer.Enabled = false;
if (!config.PROCESS_AUTO_UPDATE && autoStart)
return;

if (config.SELECTION_DIRECTORIES == null || willAbort || isRunning)
{
mediaRefreshTimer.Enabled = true;
return;
}

mediaRefreshTimer.Enabled = false;

Directory.CreateDirectory("Scribe\\storage\\_queue");

Expand Down Expand Up @@ -219,17 +213,17 @@ private void ProcessMedia()
if (willAbort)
{
willAbort = false;
return;
break;
}

isRunning = true;

string mediaQueueName = Path.GetFileNameWithoutExtension(mediaQueue[i]);
string mediaQueueMediaPath = File.ReadAllText(mediaQueue[i]);

if (!File.Exists(mediaQueueMediaPath) || !File.Exists(mediaQueue[i]))
continue;

isRunning = true;

try
{
Invoke((MethodInvoker)delegate
Expand Down Expand Up @@ -315,8 +309,7 @@ private void ProcessMedia()

File.WriteAllText("Scribe\\latest.log", log);

if (config.PROCESS_AUTO_UPDATE)
UpdateMediaRefreshTimer(60);
mediaRefreshTimer.Enabled = true;
}

private void UpdateSearch()
Expand Down Expand Up @@ -512,7 +505,7 @@ private void ProcessUpdateButton_Click(object sender, EventArgs e)
if (!isRunning)
willAbort = false;

Task.Run(() => ProcessMedia());
Task.Run(() => ProcessMedia(false));
}

private void ProcessEnableStartWithWindowsCheckBox_CheckedChanged(object sender, EventArgs e)
Expand Down

0 comments on commit 7a60b75

Please sign in to comment.