public static bool DownloadExistsLocal(IAdditionalContent content) { string downloadPath = content.GetDownloadPath(); if (File.Exists(downloadPath)) { return true; } if (Directory.Exists(downloadPath)) { string[] files = Directory.GetFiles(downloadPath); if ((files.Length == 0) && (Directory.GetDirectories(downloadPath).Length > 0)) { return true; } if (files.Length > 1) { return true; } if (files.Length == 1) { if (files[0].EndsWith(".partial")) { return false; } return true; } return false; } return false; }
public static void ViewInExplorer(IAdditionalContent content) { ThreadPool.QueueUserWorkItem(delegate (object s) { if (Directory.Exists(content.GetDownloadPath())) { Process.Start(content.GetDownloadPath()); } }); }
public static void DeleteMyContent(IAdditionalContent content, bool allVersions, bool deleteLocal, bool suppressRefresh) { mDeletingMyContent = true; ThreadPool.QueueUserWorkItem(delegate (object s) { try { QuazalQuery query; if (BeginDeleteMyContent != null) { BeginDeleteMyContent(new ContentOperationCallbackArgs(content, null)); } if (deleteLocal) { DateTime now = DateTime.Now; while (!content.DeleteMyContent(allVersions)) { if ((DateTime.Now - now) > TimeSpan.FromSeconds(3.0)) { break; } Thread.Sleep(50); } if (Directory.Exists(content.GetDownloadPath())) { DlgMessage.Show(Program.MainForm, "<LOC>Error", string.Format("<LOC>Unable to delete directory {0}, ensure it's files are not in use elsewhere.", content.GetDownloadPath())); if (FinishDeleteMyContent != null) { FinishDeleteMyContent(new ContentOperationCallbackArgs(content, null, false, new object[] { allVersions })); } return; } } if (allVersions) { query = new QuazalQuery("DeleteDownloadedContentVersions", new object[] { content.TypeID, content.Name }); } else { query = new QuazalQuery("DeleteDownloadedContent", new object[] { content.ID }); } bool success = query.ExecuteNonQuery(); mDeletingMyContent = false; if (!(suppressRefresh || (FinishDeleteMyContent == null))) { FinishDeleteMyContent(new ContentOperationCallbackArgs(content, null, success, new object[] { allVersions })); } } catch (Exception exception) { ErrorLog.WriteLine(exception); mDeletingMyContent = false; if (FinishDeleteMyContent != null) { FinishDeleteMyContent(new ContentOperationCallbackArgs(content, null, false, new object[] { allVersions })); } } }); }