Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
vDeggial committed Dec 13, 2014
1 parent 5308732 commit 6a578ad
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Tumbl Tool/Enums/processingCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public enum processingCodes
saveFileOK,
saveFileError,
Done,
Error
Error,
SavingLogFile
}
}
23 changes: 12 additions & 11 deletions Tumbl Tool/Image Ripper/ImageRipper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Tumblr_Tool.Enums;
using Tumblr_Tool.Managers;
using Tumblr_Tool.Tumblr_Objects;
using System.Linq;

namespace Tumblr_Tool.Image_Ripper
{
Expand All @@ -41,9 +42,11 @@ public class ImageRipper
private int offset = 0;
private HashSet<TumblrPost> oldPosts;
private bool parsePhotoSets, parseJPEG, parsePNG, parseGIF;
private string saveLocation;
public string saveLocation;
private string tumblrDomain = "";

public bool logUpdated;

public ImageRipper()
{
}
Expand Down Expand Up @@ -259,10 +262,12 @@ public TumblrBlog parseBlogPosts(int parseMode)
generateImageListForDownload(blog.posts);
percentComplete = totalPosts > 0 ? (int)(((double)parsed / (double)totalPosts) * 100.00) : 0;
i += step;

if (this.generateLog)
{
saveLogFile(blog.name);
}

blog.posts.Clear();
}
}
Expand Down Expand Up @@ -293,21 +298,17 @@ public void saveLogFile(string name)

public void saveLogFile(SaveFile log)
{
bool logUpdated = false;

foreach (TumblrPost post in blog.posts)
{
if (!log.blog.posts.ToList().Exists(p => p.id == post.id))


if (!log.blog.posts.Any(p => p.id == post.id))
{
log.blog.posts.Add(post);
logUpdated = true;
this.logUpdated = true;
}
}

if (logUpdated)
{
FileManager fileManager = new FileManager();
fileManager.saveTumblrFile(saveLocation + @"\" + log.getFileName(), log);
}
}

public void setAPIMode(string mode)
Expand All @@ -330,7 +331,7 @@ public bool setBlogInfo()
return crawlManager.setBlogInfo(query, this.blog);
}

public void setLogFile(SaveFile log)
public void setLogFile(ref SaveFile log)
{
this.log = log;
}
Expand Down
48 changes: 47 additions & 1 deletion Tumblr Tool UI/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,22 @@ private void crawlUIWorker_DoWork(object sender, DoWorkEventArgs e)
}
}


if (ripper.statusCode == processingCodes.SavingLogFile)
{
lock (ripper)
{
if (!this.IsDisposed)
{
this.Invoke((MethodInvoker)delegate
{
updateStatusText("Saving Log File");
updateWorkStatusText("Saving Log File ...");
});
}
}
}

if (ripper.statusCode == processingCodes.Starting)
{
lock (ripper)
Expand Down Expand Up @@ -699,6 +715,8 @@ private void crawlWorker_AfterDone(object sender, RunWorkerCompletedEventArgs e)
if (ripper.statusCode == processingCodes.Done)
{
saveFile.blog = ripper.blog;
logFile = null;
ripper.log = null;

if (!optionsForm.parseOnly)
{
Expand Down Expand Up @@ -762,7 +780,7 @@ private void crawlWorker_DoWork(object sender, DoWorkEventArgs e)
if (this.ripper != null)
{
this.ripper.setAPIMode(options.apiMode);
this.ripper.setLogFile(logFile);
this.ripper.setLogFile(ref logFile);

if (ripper.isValidTumblr())
{
Expand Down Expand Up @@ -806,6 +824,34 @@ private void crawlWorker_DoWork(object sender, DoWorkEventArgs e)
}

tumblrBlog = this.ripper.parseBlogPosts(mode);

if (ripper.logUpdated)
{
lock (ripper)
{
ripper.statusCode = processingCodes.SavingLogFile;

if (!this.IsDisposed)
{
this.Invoke((MethodInvoker)delegate
{
updateStatusText("Saving Log File");
updateWorkStatusText("Saving Log File ...");
});
}

fileManager.saveTumblrFile(ripper.saveLocation + @"\" + ripper.log.getFileName(), ripper.log);

if (!this.IsDisposed)
{
this.Invoke((MethodInvoker)delegate
{
updateStatusText("Log Saved");
updateWorkStatusText("Log file saved");
});
}
}
}
}
}

Expand Down

0 comments on commit 6a578ad

Please sign in to comment.