Skip to content

Commit

Permalink
Fixed Crash from Issue #1
Browse files Browse the repository at this point in the history
Now if the associated directory is not present for an ACF file, it will
report size 0, and will no longer crash when trying to copy, but the
copy will still fail.
  • Loading branch information
DjScribbles committed Feb 25, 2016
1 parent cbc29b2 commit 425ca41
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions GamePipeLib/Model/Steam/SteamApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public enum AppStateFlags
public class SteamApp : GamePipeLib.Model.NotifyPropertyChangedBase, ISteamApplication
{
private System.IO.FileSystemWatcher _watcher;
private long _acfDiskSize;
public SteamApp(string acfFilePath)
{
_AcfFile = acfFilePath;
Expand All @@ -56,8 +57,13 @@ public void MeasureDiskSize()
{
if (!_isMeasured)
{
var info = new DirectoryInfo(GameDir);
DiskSize = info.EnumerateFiles("*", SearchOption.AllDirectories).Sum(x => x.Length);
if (Directory.Exists(GameDir))
{
var info = new DirectoryInfo(GameDir);
DiskSize = info.EnumerateFiles("*", SearchOption.AllDirectories).Sum(x => x.Length);
}
else
DiskSize = 0;
_isMeasured = true;
}
}
Expand Down Expand Up @@ -134,7 +140,12 @@ public void InitializeFromAcf()
int count = 0;
foreach (var pair in pairs)
{
if (count >= 5) return; //return once we've got what we're looking for
if (count >= 5)
{
if (!Directory.Exists(GameDir))
DiskSize = 0;
return; //return once we've got what we're looking for
}
switch (pair.Item1.ToLower()) //Compare in lower case
{
case "appid":
Expand All @@ -147,6 +158,7 @@ public void InitializeFromAcf()
break;
case "sizeondisk":
DiskSize = long.Parse(pair.Item2);
_acfDiskSize = DiskSize;
count++;
break;
case "name":
Expand Down Expand Up @@ -187,7 +199,13 @@ public void RefreshFromAcf()
count++;
break;
case "sizeondisk":
DiskSize = long.Parse(pair.Item2);
var newDiskSize = long.Parse(pair.Item2);
if (newDiskSize != _acfDiskSize)
{
DiskSize = newDiskSize;
_acfDiskSize = DiskSize;
_isMeasured = false;
}
count++;
break;
}
Expand Down

0 comments on commit 425ca41

Please sign in to comment.