• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

D wrapper around (some) of the pixiv web API


Commit MetaInfo

Revisão869a0746613c11612782b50a319907737443b5e2 (tree)
Hora2023-08-13 16:32:54
Autorsupercell <stigma@disr...>
Commitersupercell

Mensagem de Log

Add PageAlreadyDownloadedEvent signal

This indicates that a page in a multi-paged Illustration has already
been downloaded.

Mudança Sumário

Diff

--- a/source/pixivd/client.d
+++ b/source/pixivd/client.d
@@ -25,8 +25,25 @@ struct DownloadProgressEvent
2525 size_t current;
2626 }
2727
28+///
29+/// Signals that a download has finished. This is used for
30+/// Illustrations, Manga, and Ugoira.
31+///
32+/// The `forPage` member indicates that this signal is for
33+/// an individual page of the Illustration or Manga only.
34+///
2835 struct DownloadCompleteEvent
2936 {
37+ /// Is the download for an individual page?
38+ const bool forPage = false;
39+}
40+
41+///
42+/// Signals that a page in the Illustration has already
43+/// been downloaded and will not be downloaded again.
44+///
45+struct PageAlreadyDownloadedEvent
46+{
3047 }
3148
3249 /**
@@ -109,6 +126,7 @@ public:
109126 /* Signals */
110127 mixin Signal!(DownloadProgressEvent);
111128 mixin Signal!(DownloadCompleteEvent);
129+ mixin Signal!(PageAlreadyDownloadedEvent);
112130
113131 /**
114132 * Fetch an illustration
@@ -805,6 +823,11 @@ private:
805823 const partFileName = baseFileName ~ ".part";
806824 string mode = "w+";
807825
826+ if (true == exists(baseFileName) && false == overwrite) {
827+ emit(PageAlreadyDownloadedEvent());
828+ continue;
829+ }
830+
808831 if (true == exists(partFileName)) {
809832 this._setupPartialDownload(jsonobj["urls"]["original"].str, partFileName);
810833 mode = "a+";
@@ -827,8 +850,9 @@ private:
827850 m_client.perform();
828851 img.close();
829852 rename(partFileName, baseFileName);
830- emit(DownloadCompleteEvent());
853+ emit(DownloadCompleteEvent(true));
831854 }
855+ emit(DownloadCompleteEvent());
832856 }
833857
834858 void _downloadManga(Illustration illust, string directory, bool overwrite)