Skip to content

Commit 44c4f9d

Browse files
committed
Release update to version 4, fixes #114 and #112
1 parent 2cdee05 commit 44c4f9d

20 files changed

+360
-211
lines changed

CHANGELOG.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1+
2018.08.24 | FileMasta 4.1
2+
3+
CHANGE: CORE | Fixed #114
4+
CHANGE: CORE | Fixed #112
5+
CHANGE: CORE | Improved code efficiency
6+
CHANGE: CORE | Added error retry attempts
7+
CHANGE: UI | Re-added external search engines
8+
CHANGE: UI | Minor interface adjustments
9+
10+
11+
12+
113
2018.06.28 | FileMasta 4.0
214

315
CHANGE: CORE | Datatabase now uses FTP servers/files
416
CHANGE: CORE | Improved crawler, faster and more efficient
517
CHANGE: CORE | All file extensions/types supported
618
CHANGE: UI | Standard winform interface
719
CHANGE: UI | Added right-click options to files
8-
CHANGE: UI | Added boomarks window,
20+
CHANGE: UI | Added boomarks window
921
CHANGE: UI | Added menu and status toolbar
1022
CHANGE: UI | Added browsers to external apps
1123

FileMasta/Extensions/ImageExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static Bitmap ChangeColor(Bitmap scrBitmap, Color newColor)
3131
}
3232
return newBitmap;
3333
}
34-
catch (Exception ex) { Program.log.Error("Error changing image colour", ex); return null; }
34+
catch (Exception ex) { Program.Log.Error("Error changing image colour", ex); return null; }
3535
}
3636
}
3737
}

FileMasta/Extensions/LocalExtensions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ class LocalExtensions
1111
public static string PathRoot { get; } = $@"{Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}\FileMasta\";
1212
public static string PathData { get; } = $@"{PathRoot}Data\";
1313
public static string PathDownloadsDirectory { get; } = $@"{KnownFolders.GetPath(KnownFolder.Downloads)}\";
14-
public static string PathVideosDirectory { get; } = $@"{KnownFolders.GetPath(KnownFolder.Videos)}\";
15-
public static string PathMusicDirectory { get; } = $@"{KnownFolders.GetPath(KnownFolder.Music)}\";
16-
public static string PathDocumentsDirectory { get; } = $@"{KnownFolders.GetPath(KnownFolder.Documents)}\";
17-
public static string PathDesktopDirectory { get; } = $@"{KnownFolders.GetPath(KnownFolder.Desktop)}\";
1814
public static string PathBookmarks { get; } = $@"{PathRoot}bookmarked.json";
1915

2016
/// <summary>

FileMasta/Extensions/StringExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,4 @@ public static bool IsValidJSON(string json)
162162
}
163163
}
164164
}
165-
}
165+
}

FileMasta/FileMasta.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@
9494
<Reference Include="System.Xml" />
9595
</ItemGroup>
9696
<ItemGroup>
97+
<Compile Include="Extensions\ImageExtensions.cs" />
9798
<Compile Include="Windows\FileDetailsWindow.cs">
9899
<SubType>Form</SubType>
99100
</Compile>
100101
<Compile Include="Windows\FileDetailsWindow.Designer.cs">
101102
<DependentUpon>FileDetailsWindow.cs</DependentUpon>
102103
</Compile>
103-
<Compile Include="Extensions\ImageExtensions.cs" />
104104
<Compile Include="Windows\AboutWindow.cs">
105105
<SubType>Form</SubType>
106106
</Compile>

FileMasta/Files/Bookmarks.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static bool IsBookmarked(string url)
5959
/// <returns>Bookmark item as a WebFile</returns>
6060
public static List<FtpFile> BookmarkedFiles()
6161
{
62-
Program.log.Info("Getting users bookmarks files");
62+
Program.Log.Info("Getting users bookmarks files");
6363

6464
var filesBookmarks = new List<FtpFile>();
6565
if (File.Exists(LocalExtensions.PathBookmarks))
@@ -72,10 +72,10 @@ public static List<FtpFile> BookmarkedFiles()
7272
}
7373
catch (Exception ex)
7474
{
75-
Program.log.Error("Unable to get bookmarks", ex);
75+
Program.Log.Error("Unable to get bookmarks", ex);
7676
}
7777

78-
Program.log.Info("Users bookmarks returned successful");
78+
Program.Log.Info("Users bookmarks returned successful");
7979

8080
return filesBookmarks;
8181
}
@@ -85,14 +85,14 @@ public static List<FtpFile> BookmarkedFiles()
8585
/// </summary>
8686
public static void ClearBookmarks()
8787
{
88-
Program.log.Info("Clearing all bookmarks");
88+
Program.Log.Info("Clearing all bookmarks");
8989

9090
var filesBookmarks = new List<FtpFile>();
9191
if (File.Exists(LocalExtensions.PathBookmarks))
9292
using (StreamWriter stream = File.CreateText(LocalExtensions.PathBookmarks))
9393
stream.Flush();
9494

95-
Program.log.Info("Bookmarks cleared successfully");
95+
Program.Log.Info("Bookmarks cleared successfully");
9696
}
9797
}
9898
}

FileMasta/Files/Database.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,68 +14,68 @@ class Database
1414
/// <summary>
1515
/// URLs for database files
1616
/// </summary>
17-
const string dbOpenFiles = "https://www.dropbox.com/s/0dwmqk1pkj2ndkz/ftp-files.json?raw=true";
18-
const string dbOpenServers = "https://raw.githubusercontent.com/HerbL27/FileMasta/master/Public/ftp-servers.txt";
19-
public const string dbTopSearches = "https://www.dropbox.com/s/512qe4ogan92vea/top-searches.txt?raw=true";
17+
const string DbOpenFiles = "https://www.dropbox.com/s/0dwmqk1pkj2ndkz/ftp-files.json?raw=true";
18+
const string DbOpenServers = "https://raw.githubusercontent.com/HerbL27/FileMasta/master/Public/ftp-servers.txt";
19+
public const string DbTopSearches = "https://www.dropbox.com/s/512qe4ogan92vea/top-searches.txt?raw=true";
2020

2121
/// <summary>
2222
/// Database file names
2323
/// </summary>
24-
const string fileNameFiles = "ftp-files.json";
25-
const string fileNameServers = "ftp-servers.txt";
24+
const string FileNameFiles = "ftp-files.json";
25+
const string FileNameServers = "ftp-servers.txt";
2626

2727
/// <summary>
2828
/// Checks if database files exists at users data directory, if so whether they're
2929
/// the same size, and downloads the latest one if either return false
3030
/// </summary>
3131
public static void UpdateLocalDatabase()
3232
{
33-
Program.log.Info("Starting database updates");
33+
Program.Log.Info("Starting database updates");
3434

3535
try
3636
{
37-
if (IsFileOutOfDate(dbOpenFiles, fileNameFiles))
37+
if (IsFileOutOfDate(DbOpenFiles, FileNameFiles))
3838
{
39-
Program.log.Info($"Updating {fileNameFiles}...");
39+
Program.Log.Info($"Updating {FileNameFiles}...");
4040
using (var client = new WebClient())
41-
client.DownloadFile(new Uri(dbOpenFiles), $"{LocalExtensions.PathData}{fileNameFiles}");
42-
Program.log.Info($"{fileNameFiles} updated");
41+
client.DownloadFile(new Uri(DbOpenFiles), $"{LocalExtensions.PathData}{FileNameFiles}");
42+
Program.Log.Info($"{FileNameFiles} updated");
4343
}
4444
}
4545
catch (Exception ex)
4646
{
47-
Program.log.Error($"Failed to update {fileNameFiles}", ex);
47+
Program.Log.Error($"Failed to update {FileNameFiles}", ex);
4848
MessageBox.Show(MainForm.Form, "Unable to update database.\n\n" + ex.Message);
4949
}
5050
finally
5151
{
5252
// Deserializes database first line containing meta info
53-
MainForm.DbMetaData = JsonConvert.DeserializeObject<Metadata>(File.ReadLines($"{LocalExtensions.PathData}{fileNameFiles}").First());
53+
MainForm.DbMetaData = JsonConvert.DeserializeObject<Metadata>(File.ReadLines($"{LocalExtensions.PathData}{FileNameFiles}").First());
5454

5555
// Store files in the main form, skipping the first line as it contains the db metadata
56-
foreach (var item in File.ReadAllLines($"{LocalExtensions.PathData}{fileNameFiles}").Skip(1))
56+
foreach (var item in File.ReadLines($"{LocalExtensions.PathData}{FileNameFiles}").Skip(1))
5757
if (StringExtensions.IsValidJSON(item))
5858
MainForm.DbOpenFiles.Add(JsonConvert.DeserializeObject<FtpFile>(item));
5959
}
6060

6161
try
6262
{
63-
if (IsFileOutOfDate(dbOpenServers, fileNameServers))
63+
if (IsFileOutOfDate(DbOpenServers, FileNameServers))
6464
{
65-
Program.log.Info($"Updating {fileNameServers}...");
65+
Program.Log.Info($"Updating {FileNameServers}...");
6666
using (var client = new WebClient())
67-
client.DownloadFile(new Uri(dbOpenServers), $"{LocalExtensions.PathData}{fileNameServers}");
68-
Program.log.Info($"{fileNameServers} updated");
67+
client.DownloadFile(new Uri(DbOpenServers), $"{LocalExtensions.PathData}{FileNameServers}");
68+
Program.Log.Info($"{FileNameServers} updated");
6969
}
7070
}
7171
catch (Exception ex)
7272
{
73-
Program.log.Error($"UPDATE FAILED {fileNameServers}", ex);
73+
Program.Log.Error($"UPDATE FAILED {FileNameServers}", ex);
7474
MessageBox.Show(MainForm.Form, "Unable to update database.\n\n" + ex.Message);
7575
}
7676
finally
7777
{
78-
MainForm.DbOpenServers.AddRange(File.ReadAllLines($"{LocalExtensions.PathData}{fileNameServers}"));
78+
MainForm.DbOpenServers.AddRange(File.ReadLines($"{LocalExtensions.PathData}{FileNameServers}"));
7979
}
8080
}
8181

@@ -89,7 +89,7 @@ public static bool IsFileOutOfDate(string webFile, string fileName)
8989
{
9090
try
9191
{
92-
Program.log.Info($"Checking if '{fileName}' needs to be updated");
92+
Program.Log.Info($"Checking if '{fileName}' needs to be updated");
9393

9494
if (File.Exists($"{LocalExtensions.PathData}{fileName}"))
9595
if (WebExtensions.WebFileSize($"{webFile}") == new FileInfo($"{LocalExtensions.PathData}{fileName}").Length)
@@ -99,7 +99,7 @@ public static bool IsFileOutOfDate(string webFile, string fileName)
9999
else
100100
return true;
101101
}
102-
catch (Exception ex) { Program.log.Error($"Unable to check '{fileName}' for update, URL : {webFile}", ex); return true; }
102+
catch (Exception ex) { Program.Log.Error($"Unable to check '{fileName}' for update, URL : {webFile}", ex); return true; }
103103
}
104104

105105
/// <summary>

FileMasta/Files/Query.cs

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5-
using System.Reflection;
6-
using System.Text.RegularExpressions;
75
using FileMasta.Extensions;
86
using FileMasta.Models;
97

@@ -25,42 +23,39 @@ public enum Sort { Name, Size, Date }
2523
/// <param name="type">Filter by type</param>
2624
/// <param name="host">Filter by FTP host</param>
2725
/// <returns>Returns list of files matching selected preferences</returns>
28-
static readonly object LoadSearchListLock = new object();
26+
static readonly object SearchLock = new object();
2927
public static List<FtpFile> Search(List<FtpFile> dataFiles, string phrase, Sort sort, string[] type, string host)
3028
{
31-
lock (LoadSearchListLock)
29+
lock (SearchLock)
3230
{
33-
bool reverseSort = sort == MainForm.Form.SelectedFilesSort;
34-
SortFiles(dataFiles, sort, reverseSort);
35-
36-
return dataFiles.Select(item =>
37-
new
38-
{
39-
i = item,
40-
Props = item.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)
41-
})
42-
.Where(item => item.Props.Any(p =>
43-
{
44-
var val = p.GetValue(item.i, null);
45-
return val != null
46-
&& (p.Name == "URL" || string.IsNullOrEmpty("URL"))
47-
&& HasFileExtension(type, val.ToString())
48-
&& HasFileHost(host, val.ToString())
49-
&& StringExtensions.ContainsAll(Uri.UnescapeDataString(val.ToString()), StringExtensions.GetWords(phrase.ToLower()));
50-
}))
51-
.Select(item => item.i)
52-
.ToList();
31+
SortFiles(dataFiles, sort, sort == MainForm.Form.SelectedFilesSort);
32+
return dataFiles.Where(x =>
33+
HasFileType(type, x.URL) &&
34+
HasFileHost(host, x.URL) &&
35+
StringExtensions.ContainsAll(Uri.UnescapeDataString(x.URL), StringExtensions.GetWords(phrase.ToLower()))).ToList();
5336
}
5437
}
5538

56-
public static bool HasFileExtension(string[] type, string fileUrl)
39+
/// <summary>
40+
/// Returns bool to determine if file URL contains file type
41+
/// </summary>
42+
/// <param name="type">Filetypes to check for</param>
43+
/// <param name="fileUrl">File URL</param>
44+
/// <returns>Returns true if is filetype</returns>
45+
public static bool HasFileType(string[] type, string fileUrl)
5746
{
5847
if (type == Types.Everything)
5948
return true;
6049
else
6150
return type.Any(x => Path.GetExtension(fileUrl).Replace(".", "").ToLower().Contains(x.ToLower()));
6251
}
6352

53+
/// <summary>
54+
/// Returns bool to determine if file URL has file host
55+
/// </summary>
56+
/// <param name="host">Host to check for</param>
57+
/// <param name="fileUrl">File URL</param>
58+
/// <returns></returns>
6459
public static bool HasFileHost(string host, string fileUrl)
6560
{
6661
if (host == "")

0 commit comments

Comments
 (0)