Skip to content

Commit d36e04a

Browse files
committed
2.5.1.0 - Fixed issues with the SFTP client and failed screenshot uploads to an SFTP server. A null reference exception error would be thrown during a series of attempts in uploading screenshots that previously failed to upload causing the user to exit the application and start the application again (thereby voiding the failed upload process). It was also discovered that, when screenshots that had previously failed to upload, would upload successfully later (after establishing a successful connection with the SFTP server) the screenshots would be uploaded to the incorrect location. They would be uploaded based on the Folder path and the Macro path instead of simply the Macro path (as they usually do upon successful upload). Now screenshots that previously failed to upload will be uploaded based on the Macro path to keep it consistent with how sucessfully uploaded screenshots are handled.
1 parent 865978f commit d36e04a

File tree

8 files changed

+51
-53
lines changed

8 files changed

+51
-53
lines changed

AutoScreenCaptureSetup/AutoScreenCaptureSetup.vdproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,15 @@
259259
{
260260
"Name" = "8:Microsoft Visual Studio"
261261
"ProductName" = "8:Auto Screen Capture"
262-
"ProductCode" = "8:{23F9442C-D935-4974-B060-2AE627EFD750}"
263-
"PackageCode" = "8:{AC9F2877-9900-4F45-A3B3-2826555A7597}"
262+
"ProductCode" = "8:{1BA6261F-F580-404D-873D-A2BB82E6D83D}"
263+
"PackageCode" = "8:{C456F1EE-5A83-4F4F-B98F-BE49590A7F28}"
264264
"UpgradeCode" = "8:{6B29B7BC-0101-4495-B28C-26B6D3CDCC02}"
265265
"AspNetVersion" = "8:4.0.30319.0"
266266
"RestartWWWService" = "11:FALSE"
267267
"RemovePreviousVersions" = "11:TRUE"
268268
"DetectNewerInstalledVersion" = "11:TRUE"
269269
"InstallAllUsers" = "11:TRUE"
270-
"ProductVersion" = "8:2.5.09"
270+
"ProductVersion" = "8:2.5.10"
271271
"Manufacturer" = "8:Gavin Kendall"
272272
"ARPHELPTELEPHONE" = "8:"
273273
"ARPHELPLINK" = "8:https://sourceforge.net/p/autoscreen/tickets/"

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.5.0.9")]
36-
[assembly: AssemblyFileVersion("2.5.0.9")]
35+
[assembly: AssemblyVersion("2.5.1.0")]
36+
[assembly: AssemblyFileVersion("2.5.1.0")]
3737
[assembly: NeutralResourcesLanguageAttribute("en-CA")]

app.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<assemblyIdentity
44
type="win32"
55
name="GavinKendall.AutoScreenCapture"
6-
version="2.5.0.9"/>
6+
version="2.5.1.0"/>
77
<asmv3:application>
88
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
99
<dpiAware>True/PM</dpiAware>

autoscreen.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# The version of Auto Screen Capture that this configuration file is intended for.
3030
# Be careful if you change the version number and don't provide the correct definitions for the specific version
3131
# as some settings will only work with certain versions of the application. Versioning of the configuration file starts with Auto Screen Capture 2.5.0.0 ("Limoncello").
32-
Version=2.5.0.9
32+
Version=2.5.1.0
3333

3434
# Starting with version 2.5.0.0 the entire configuration file defines all the default application and user settings
3535
# that were previously hard-coded within the application itself. Now you have the ability to define all of the default settings in a single file!

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Auto Screen Capture by Gavin Kendall
22

3+
2.5.1.0 Fixed issues with the SFTP client and failed screenshot uploads to an SFTP server. A null reference exception error would be thrown during a series of attempts in uploading screenshots that previously failed to upload causing the user to exit the application and start the application again (thereby voiding the failed upload process). It was also discovered that, when screenshots that had previously failed to upload, would upload successfully later (after establishing a successful connection with the SFTP server) the screenshots would be uploaded to the incorrect location. They would be uploaded based on the Folder path and the Macro path instead of simply the Macro path (as they usually do upon successful upload). Now screenshots that previously failed to upload will be uploaded based on the Macro path to keep it consistent with how sucessfully uploaded screenshots are handled.
34
2.5.0.9 Fixed bug if you opened the application without having Dashboard as your selected tab view on startup.
45
2.5.0.8 Fixed issue with SFTP settings when FileTransferIsLinuxServer setting was not available in sftp.xml due to an upgrade from an old version of the application. Added Preview, Start Screen Capture, and Stop Screen Capture buttons to Dashboard. Dynamic Regex Validator and Encryptor/Decryptor tool windows no longer "float"; they now behave like normal non-floating windows. Fixed startup issue when upgrading from an old version of the application and using the wrong version of the config file.
56
2.5.0.7 Fixed modules panel open state so it no longer affects width of tabs view if modules panel's state is open during LoadSettings.

interface/main/FormMain-Screenshots.cs

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ namespace AutoScreenCapture
3030
{
3131
public partial class FormMain : Form
3232
{
33-
// A dictionary of failed uploads containing filepaths and hosts.
34-
private Dictionary<string, string> _failedUploads = new Dictionary<string, string>();
33+
// A dictionary of failed uploads containing screenshots and hosts.
34+
private Dictionary<Screenshot, string> _failedUploads = new Dictionary<Screenshot, string>();
3535

3636
/// <summary>
3737
/// Saves screenshot references every five minutes (300000 milliseconds).
@@ -1118,12 +1118,12 @@ private bool FileTransferScreenshot(Screenshot screenshot)
11181118

11191119
if (Convert.ToBoolean(_config.Settings.User.GetByKey("SFTPKeepFailedUploads").Value))
11201120
{
1121-
// Add the screenshot filepath and host to a dictionary of failed uploads so we'll attempt to upload the screenshot for that host later.
1122-
if (!_failedUploads.ContainsKey(screenshot.FilePath))
1121+
// Add the screenshot and host to a dictionary of failed uploads so we'll attempt to upload the screenshot for that host later.
1122+
if (!_failedUploads.ContainsKey(screenshot))
11231123
{
1124-
_log.WriteDebugMessage($"Screenshot ({screenshot.FilePath}) has been added to the dictionary of failed uploads because a connection to the file server could not be established at this time so an attempt to retry the upload will occur in the next capture cycle");
1124+
_log.WriteDebugMessage($"Screenshot ({screenshot.MacroPath}) has been added to the dictionary of failed uploads because a connection to the file server could not be established at this time so an attempt to retry the upload will occur in the next capture cycle");
11251125

1126-
_failedUploads.Add(screenshot.FilePath, host);
1126+
_failedUploads.Add(screenshot, host);
11271127
}
11281128
}
11291129

@@ -1135,23 +1135,23 @@ private bool FileTransferScreenshot(Screenshot screenshot)
11351135
if (_sftpClient.IsConnected)
11361136
{
11371137
// This is necessary since we are going to be removing entries from the _failedUploads dictionary while enumerating the collection
1138-
// so instead of modifying the collection that we're enumerating it's better to simply enumerate over a copy of the filepaths.
1139-
string[] pathsOfFailedUploads = new string[_failedUploads.Count];
1140-
_failedUploads.Keys.CopyTo(pathsOfFailedUploads, 0);
1138+
// so instead of modifying the collection that we're enumerating it's better to simply enumerate over a copy of the screenshots.
1139+
Screenshot[] screenshotsThatFailedToUpload = new Screenshot[_failedUploads.Count];
1140+
_failedUploads.Keys.CopyTo(screenshotsThatFailedToUpload, 0);
11411141

1142-
foreach (string path in pathsOfFailedUploads)
1142+
foreach (Screenshot screenshotThatFailedToUpload in screenshotsThatFailedToUpload)
11431143
{
1144-
if (_failedUploads.ContainsKey(path))
1144+
if (_failedUploads.ContainsKey(screenshotThatFailedToUpload))
11451145
{
1146-
if (_failedUploads.TryGetValue(path, out string hostAssociatedWithPath))
1146+
if (_failedUploads.TryGetValue(screenshotThatFailedToUpload, out string hostAssociatedWithPath))
11471147
{
1148-
_log.WriteDebugMessage($"Screenshot ({path}) was found in dictionary of failed uploads");
1148+
_log.WriteDebugMessage($"Screenshot ({screenshotThatFailedToUpload.MacroPath}) was found in dictionary of failed uploads");
11491149

1150-
// Make sure that the host associated with the path is equal to the host we're currently handling
1150+
// Make sure that the host associated with the screenshot is equal to the host we're currently handling
11511151
// so we don't accidentally upload the screenshot to the wrong SFTP server just in case the user changes hosts.
11521152
if (hostAssociatedWithPath.Equals(host))
11531153
{
1154-
if (UploadScreenshot(host, path, path))
1154+
if (UploadScreenshot(screenshotThatFailedToUpload, host))
11551155
{
11561156
_log.WriteDebugMessage($"This screenshot previously failed to upload. It has now been successfully uploaded to {host}");
11571157
}
@@ -1165,7 +1165,7 @@ private bool FileTransferScreenshot(Screenshot screenshot)
11651165
}
11661166

11671167
// Upload the screenshot we're currently handling.
1168-
return UploadScreenshot(host, screenshot.FilePath, screenshot.MacroPath);
1168+
return UploadScreenshot(screenshot, host);
11691169
}
11701170

11711171
return false;
@@ -1184,45 +1184,44 @@ private bool FileTransferScreenshot(Screenshot screenshot)
11841184
}
11851185

11861186
/// <summary>
1187-
/// Uploads a screenshot image file to the SFTP server given the provided local filepath and macro path of the screenshot.
1187+
/// Uploads a screenshot image file to the SFTP server.
11881188
/// </summary>
1189+
/// <param name="screenshot">The screenshot we want to upload to the SFTP server.</param>
11891190
/// <param name="host">The hostname for the SFTP server.</param>
1190-
/// <param name="path">The local filepath of the screenshot.</param>
1191-
/// <param name="macroPath">The screenshot's macro path (filename pattern) which will be used for the remote directory on the SFTP server.</param>
11921191
/// <returns>True if the upload was successful. False if the upload failed.</returns>
1193-
private bool UploadScreenshot(string host, string path, string macroPath)
1192+
private bool UploadScreenshot(Screenshot screenshot, string host)
11941193
{
1195-
string destinationFolder = Path.GetDirectoryName(macroPath);
1196-
string destinationFilename = Path.GetFileName(macroPath);
1194+
string destinationFolder = Path.GetDirectoryName(screenshot.MacroPath);
1195+
string destinationFilename = Path.GetFileName(screenshot.MacroPath);
11971196

11981197
bool isLinuxServer = Convert.ToBoolean(_config.Settings.SFTP.GetByKey("FileTransferIsLinuxServer").Value);
11991198

12001199
_log.WriteDebugMessage("Attempting to upload screenshot to file server");
1201-
_log.WriteDebugMessage("Source (Local) Path: " + path);
1200+
_log.WriteDebugMessage("Source (Local) Path: " + screenshot.FilePath);
12021201
_log.WriteDebugMessage("Destination (Remote) Folder Path: " + destinationFolder);
12031202
_log.WriteDebugMessage("Destination (Remote) Filename: " + destinationFilename);
12041203
_log.WriteDebugMessage("Is Linux Server: " + isLinuxServer.ToString());
12051204

1206-
if (_sftpClient.UploadFile(path, destinationFolder, destinationFilename, isLinuxServer))
1205+
if (_sftpClient.UploadFile(screenshot.FilePath, destinationFolder, destinationFilename, isLinuxServer))
12071206
{
12081207
_log.WriteDebugMessage("Successfully uploaded screenshot");
12091208

12101209
if (Convert.ToBoolean(_config.Settings.User.GetByKey("SFTPDeleteLocalFileAfterSuccessfulUpload").Value))
12111210
{
1212-
if (_fileSystem.FileExists(path))
1211+
if (_fileSystem.FileExists(screenshot.FilePath))
12131212
{
1214-
_fileSystem.DeleteFile(path);
1213+
_fileSystem.DeleteFile(screenshot.FilePath);
12151214

1216-
_log.WriteDebugMessage($"Screenshot ({path}) deleted locally because of successful upload to file server");
1215+
_log.WriteDebugMessage($"Screenshot ({screenshot.FilePath}) deleted locally because of successful upload to file server");
12171216
}
12181217
}
12191218

1220-
// Remove the path from the dictionary of failed uploads if we were successful in uploading the file to the SFTP server.
1221-
if (_failedUploads.ContainsKey(path))
1219+
// Remove the screenshot from the dictionary of screenshots that failed to upload if we were successful in uploading the screenshot to the SFTP server.
1220+
if (_failedUploads.ContainsKey(screenshot))
12221221
{
1223-
_log.WriteDebugMessage($"Screenshot ({path}) has been removed from the dictionary of failed uploads because the upload was successful");
1222+
_log.WriteDebugMessage($"Screenshot ({screenshot.MacroPath}) has been removed from the dictionary of failed uploads because the upload was successful");
12241223

1225-
_failedUploads.Remove(path);
1224+
_failedUploads.Remove(screenshot);
12261225
}
12271226
}
12281227
else
@@ -1231,18 +1230,15 @@ private bool UploadScreenshot(string host, string path, string macroPath)
12311230

12321231
if (Convert.ToBoolean(_config.Settings.User.GetByKey("SFTPKeepFailedUploads").Value))
12331232
{
1234-
// Add the screenshot filepath and host to a dictionary of failed uploads so we'll attempt to upload the screenshot later.
1235-
if (!_failedUploads.ContainsKey(path))
1233+
// Add the screenshot and host to a dictionary of screenshots that failed tp upload so we'll attempt to upload the screenshot later.
1234+
if (!_failedUploads.ContainsKey(screenshot))
12361235
{
1237-
_log.WriteDebugMessage($"Screenshot ({path}) has been added to the dictionary of failed uploads because the upload failed at this time so an attempt to retry the upload will occur in the next capture cycle");
1236+
_log.WriteDebugMessage($"Screenshot ({screenshot.MacroPath}) has been added to the dictionary of failed uploads because the upload failed at this time so an attempt to retry the upload will occur in the next capture cycle");
12381237

1239-
_failedUploads.Add(path, host);
1238+
_failedUploads.Add(screenshot, host);
12401239
}
12411240
}
12421241

1243-
// We can't simply say that the SFTP client is now disconnected so we just need to nullify the SFTP client.
1244-
_sftpClient = null;
1245-
12461242
return false;
12471243
}
12481244

modules/screenshots/ScreenshotCollection.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public class ScreenshotCollection
104104
/// </summary>
105105
/// <param name="screenshotsToDelete">A list of screenshots to delete.</param>
106106
/// <param name="failedUploads">A dictionary of failed uploads.</param>
107-
private void DeleteScreenshots(List<Screenshot> screenshotsToDelete, Dictionary<string, string> failedUploads)
107+
private void DeleteScreenshots(List<Screenshot> screenshotsToDelete, Dictionary<Screenshot, string> failedUploads)
108108
{
109109
lock (_screenshotList)
110110
{
@@ -115,11 +115,11 @@ private void DeleteScreenshots(List<Screenshot> screenshotsToDelete, Dictionary<
115115
_slideList.Remove(screenshot.Slide);
116116
_slideNameList.Remove(screenshot.Slide.Name);
117117

118-
// Do not delete the screenshot if the path exists in the dictionary of failed uploads.
119-
string[] filePathsOfFailedUploads = new string[failedUploads.Count];
120-
failedUploads.Keys.CopyTo(filePathsOfFailedUploads, 0);
118+
// Do not delete the screenshot if it exists in the dictionary of failed uploads.
119+
Screenshot[] screenshotsThatFailedToUpload = new Screenshot[failedUploads.Count];
120+
failedUploads.Keys.CopyTo(screenshotsThatFailedToUpload, 0);
121121

122-
if (filePathsOfFailedUploads.Contains(screenshot.FilePath))
122+
if (screenshotsThatFailedToUpload.Contains(screenshot))
123123
{
124124
continue;
125125
}
@@ -1433,7 +1433,7 @@ public void SaveToXmlFile(Config config)
14331433
/// <param name="macroParser">The macro tag parser to use.</param>
14341434
/// <param name="macroTagCollection">A collectino of macro tags.</param>
14351435
/// <param name="failedUploads">A dictionary of failed uploads.</param>
1436-
public void DeleteScreenshotsByDays(int days, string folder, MacroParser macroParser, MacroTagCollection macroTagCollection, Dictionary<string, string> failedUploads)
1436+
public void DeleteScreenshotsByDays(int days, string folder, MacroParser macroParser, MacroTagCollection macroTagCollection, Dictionary<Screenshot, string> failedUploads)
14371437
{
14381438
try
14391439
{
@@ -1503,7 +1503,7 @@ public void DeleteScreenshotsByDays(int days, string folder, MacroParser macroPa
15031503
/// </summary>
15041504
/// <param name="cycleCount">The cycle count to use when considering when to delete screenshots.</param>
15051505
/// <param name="failedUploads">A dictionary of failed uploads.</param>
1506-
public void DeleteScreenshotsByCycleCount(int cycleCount, Dictionary<string, string> failedUploads)
1506+
public void DeleteScreenshotsByCycleCount(int cycleCount, Dictionary<Screenshot, string> failedUploads)
15071507
{
15081508
try
15091509
{
@@ -1566,7 +1566,7 @@ public void DeleteScreenshotsByCycleCount(int cycleCount, Dictionary<string, str
15661566
/// Deletes screenshots from the oldest screen capture cycle. You can use this for a rolling delete given the correctly configured setup.
15671567
/// </summary>
15681568
/// <param name="failedUploads">A dictionary of failed uploads.</param>
1569-
public void DeleteScreenshotsFromOldestCaptureCycle(Dictionary<string, string> failedUploads)
1569+
public void DeleteScreenshotsFromOldestCaptureCycle(Dictionary<Screenshot, string> failedUploads)
15701570
{
15711571
try
15721572
{

settings/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ public void Initialize(FileSystem fileSystem)
281281
_versionCollection.Add(new Version(CODENAME_LIMONCELLO, "2.5.0.6"));
282282
_versionCollection.Add(new Version(CODENAME_LIMONCELLO, "2.5.0.7"));
283283
_versionCollection.Add(new Version(CODENAME_LIMONCELLO, "2.5.0.8"));
284+
_versionCollection.Add(new Version(CODENAME_LIMONCELLO, "2.5.0.9"));
284285

285286
Application = new SettingCollection()
286287
{

0 commit comments

Comments
 (0)