diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-06-05 04:23:39 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-06-05 04:23:39 +0200 |
commit | 4e10e30c2f99d552239871aa1b27a08a6c18f1a4 (patch) | |
tree | fc8426e57068733d7df20fc3a963f11cd864f079 /src/MetadataWriter.vala | |
parent | 0d64f78a02829282cd00dd6df691df08d29ed751 (diff) |
Imported Upstream version 0.23.1upstream/0.23.1
Diffstat (limited to 'src/MetadataWriter.vala')
-rw-r--r-- | src/MetadataWriter.vala | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/MetadataWriter.vala b/src/MetadataWriter.vala index 969506e..0c23260 100644 --- a/src/MetadataWriter.vala +++ b/src/MetadataWriter.vala @@ -1,4 +1,4 @@ -/* Copyright 2010-2015 Yorba Foundation +/* Copyright 2016 Software Freedom Conservancy Inc. * * This software is licensed under the GNU Lesser General Public License * (version 2.1 or later). See the COPYING file in this distribution. @@ -165,6 +165,7 @@ public class MetadataWriter : Object { private bool enabled = false; private HashTimedQueue<LibraryPhoto> dirty; private Gee.HashMap<LibraryPhoto, CommitJob> pending = new Gee.HashMap<LibraryPhoto, CommitJob>(); + private Gee.HashSet<CommitJob> pending_cancel = new Gee.HashSet<CommitJob>(); private Gee.HashSet<string> interested_photo_details = new Gee.HashSet<string>(); private LibraryPhoto? ignore_photo_alteration = null; private uint outstanding_total = 0; @@ -578,7 +579,10 @@ public class MetadataWriter : Object { bool cancelled = false; if (pending.has_key(photo)) { - pending.get(photo).cancel(); + CommitJob j = (CommitJob) pending.get(photo); + pending_cancel.add(j); + j.cancel(); + pending.unset(photo); cancelled = true; } @@ -610,6 +614,10 @@ public class MetadataWriter : Object { keywords.add(tag.get_name()); } + // check if there is already a job for that photo. if yes, cancel it. + if (pending.has_key(photo)) + cancel_job(photo); + CommitJob job = new CommitJob(this, photo, keywords); pending.set(photo, job); @@ -683,7 +691,7 @@ public class MetadataWriter : Object { } private void on_update_cancelled(BackgroundJob j) { - bool removed = pending.unset(((CommitJob) j).photo); + bool removed = pending_cancel.remove((CommitJob) j); assert(removed); count_cancelled_work(1, true); |