diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2022-10-01 21:55:21 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2022-10-01 21:55:21 +0200 |
commit | 0ac74d65f16aa7eb70669b07c25cb90114eb9435 (patch) | |
tree | 31cd86e358bc70e6d83955fdcc0d8e05fc32c325 /plugins | |
parent | 0b99aa7b114b6c8eb0d55742c4be2f3a73f44e39 (diff) | |
parent | f542481df58f3222143bc260feb34b5cf537d8e0 (diff) |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/authenticator/shotwell/TumblrAuthenticator.vala | 2 | ||||
-rw-r--r-- | plugins/shotwell-publishing/PhotosPublisher.vala | 81 |
2 files changed, 43 insertions, 40 deletions
diff --git a/plugins/authenticator/shotwell/TumblrAuthenticator.vala b/plugins/authenticator/shotwell/TumblrAuthenticator.vala index 35fdce9..8907a80 100644 --- a/plugins/authenticator/shotwell/TumblrAuthenticator.vala +++ b/plugins/authenticator/shotwell/TumblrAuthenticator.vala @@ -135,7 +135,7 @@ namespace Publishing.Authenticator.Shotwell.Tumblr { debug("attempt start: a persistent session is available; using it"); session.authenticate_from_persistent_credentials(get_persistent_access_phase_token(), - get_persistent_access_phase_token_secret(), ""); + get_persistent_access_phase_token_secret(), "unused"); } else { debug("attempt start: no persistent session available; showing login welcome pane"); diff --git a/plugins/shotwell-publishing/PhotosPublisher.vala b/plugins/shotwell-publishing/PhotosPublisher.vala index e1127ac..879f5fc 100644 --- a/plugins/shotwell-publishing/PhotosPublisher.vala +++ b/plugins/shotwell-publishing/PhotosPublisher.vala @@ -128,41 +128,28 @@ private class MediaCreationTransaction : Publishing.RESTSupport.GooglePublisher. } public override void execute () throws Spit.Publishing.PublishingError { - for (var h = 0; h * MAX_BATCH_SIZE < this.upload_tokens.length; h++) { - var offset = h * MAX_BATCH_SIZE; - var difference = this.upload_tokens.length - offset; - int end; - - if (difference > MAX_BATCH_SIZE) { - end = offset + MAX_BATCH_SIZE; - } - else { - end = offset + difference; - } - - var builder = new Json.Builder(); + var builder = new Json.Builder(); + builder.begin_object(); + builder.set_member_name("albumId"); + builder.add_string_value(this.album_id); + builder.set_member_name("newMediaItems"); + builder.begin_array(); + for (var i = 0; i < this.upload_tokens.length; i++) { builder.begin_object(); - builder.set_member_name("albumId"); - builder.add_string_value(this.album_id); - builder.set_member_name("newMediaItems"); - builder.begin_array(); - for (var i = offset; i < end; i++) { - builder.begin_object(); - builder.set_member_name("description"); - builder.add_string_value(this.titles[i]); - builder.set_member_name("simpleMediaItem"); - builder.begin_object(); - builder.set_member_name("uploadToken"); - builder.add_string_value(this.upload_tokens[i]); - builder.end_object(); - builder.end_object(); - } - builder.end_array(); + builder.set_member_name("description"); + builder.add_string_value(this.titles[i]); + builder.set_member_name("simpleMediaItem"); + builder.begin_object(); + builder.set_member_name("uploadToken"); + builder.add_string_value(this.upload_tokens[i]); + builder.end_object(); builder.end_object(); - set_custom_payload(Json.to_string (builder.get_root (), false), "application/json"); - - base.execute(); } + builder.end_array(); + builder.end_object(); + set_custom_payload(Json.to_string (builder.get_root (), false), "application/json"); + + base.execute(); } } @@ -248,6 +235,7 @@ public class Publisher : Publishing.RESTSupport.GooglePublisher { private bool running = false; private PublishingParameters publishing_parameters; private Spit.Publishing.ProgressCallback progress_reporter; + private size_t creation_offset = 0; public Publisher(Spit.Publishing.Service service, Spit.Publishing.PluginHost host) { @@ -478,15 +466,33 @@ public class Publisher : Publishing.RESTSupport.GooglePublisher { uploader.upload_complete.disconnect(on_upload_complete); uploader.upload_error.disconnect(on_upload_error); + do_media_creation_batch(uploader); + } + + private void do_media_creation_batch(Publishing.RESTSupport.BatchUploader uploader) { + var u = (Uploader) uploader; + + if (creation_offset >= u.upload_tokens.length) { + on_media_creation_complete(); + return; + } + + var end = creation_offset + MAX_BATCH_SIZE < u.upload_tokens.length ? + creation_offset + MAX_BATCH_SIZE : u.upload_tokens.length; + var txn = new MediaCreationTransaction(get_session(), - ((Uploader) uploader).upload_tokens, - ((Uploader) uploader).titles, + u.upload_tokens[creation_offset:end], + u.titles[creation_offset:end], publishing_parameters.get_target_album_entry_id()); - txn.completed.connect(on_media_creation_complete); + txn.completed.connect(() => { + do_media_creation_batch(uploader); + }); + txn.network_error.connect(on_media_creation_error); try { + creation_offset = end; txn.execute(); } catch (Spit.Publishing.PublishingError error) { on_media_creation_error(txn, error); @@ -506,10 +512,7 @@ public class Publisher : Publishing.RESTSupport.GooglePublisher { get_host().post_error(err); } - private void on_media_creation_complete(Publishing.RESTSupport.Transaction txn) { - txn.completed.disconnect(on_media_creation_complete); - txn.network_error.disconnect(on_media_creation_error); - + private void on_media_creation_complete() { if (!is_running()) return; |