Skip to content

Commit

Permalink
Update date "last updated" if download was successful
Browse files Browse the repository at this point in the history
  • Loading branch information
veronikaandersen committed Dec 10, 2018
1 parent 7751a5d commit aabf2aa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ private static async Task StartDownloadAsync(ConfigFile config)

downloadUsage?.Entries.Add(new DownloadUsageEntries(datasetFile));
updatedDatasetFileToDownload.Add(datasetFile);

}
else
{
Expand All @@ -139,6 +138,7 @@ private static async Task StartDownloadAsync(ConfigFile config)
datasetFile.FilePath = downloadHistory.FilePath;
updatedDatasetFileToDownload.Add(datasetFile);
}
datasetFile.DownloadSuccess = true;
}

catch (Exception e)
Expand All @@ -148,6 +148,7 @@ private static async Task StartDownloadAsync(ConfigFile config)
fileLog.Message = "Error while downloading dataset: " + e.Message;
downloadLog.Faild.Add(fileLog);
Console.WriteLine("Error while downloading dataset: " + e.Message);
datasetFile.DownloadSuccess = true;
}

Console.WriteLine("-------------");
Expand Down
5 changes: 5 additions & 0 deletions Lib/DatasetFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public class DatasetFile
/// </summary>
public string FilePath { get; set; }

/// <summary>
/// Check if download was successful
/// </summary>
public bool DownloadSuccess { get; set; }


public DatasetFile(DatasetFileViewModel datasetFileViewModel)
{
Expand Down
4 changes: 3 additions & 1 deletion Lib/DatasetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,9 @@ public void WriteToDownloadHistoryFile(List<Download> downloads)
{
foreach (var datasetFile in dataset.Files)
{
downloadHistory.Add(new DownloadHistory(datasetFile.Url, datasetFile.FilePath));
downloadHistory.Add(datasetFile.DownloadSuccess
? new DownloadHistory(datasetFile.Url, datasetFile.FilePath)
: new DownloadHistory(datasetFile.Url, datasetFile.FilePath, datasetFile.LastUpdated));
}
}

Expand Down
4 changes: 2 additions & 2 deletions Lib/DownloadHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ namespace Geonorge.MassivNedlasting
public class DownloadHistory
{

public DownloadHistory(string url, string filePath)
public DownloadHistory(string url, string filePath, string lastUpdated = null)
{
Id = url;
Downloaded = DateTime.Now.ToString();
Downloaded = lastUpdated ?? DateTime.Now.ToString();
FilePath = filePath;
}

Expand Down

0 comments on commit aabf2aa

Please sign in to comment.