Remove PUIDs from PUID manager when the corresponding file gets removed. This fixes a case where the PUID submission was activated again after removing a saved file.

This commit is contained in:
Philipp Wolfer
2009-03-30 22:58:41 +02:00
parent 234a3bc85a
commit 68bea4ecc5
2 changed files with 6 additions and 2 deletions

View File

@@ -317,7 +317,7 @@ class File(LockableObject, Item):
if from_parent and self.parent:
self.log.debug("Removing %r from %r", self, self.parent)
self.parent.remove_file(self)
self.tagger.puidmanager.update(self.metadata['musicip_puid'], self.metadata['musicbrainz_trackid'])
self.tagger.puidmanager.remove(self.metadata['musicip_puid'])
self.state = File.REMOVED
def move(self, parent):

View File

@@ -39,6 +39,10 @@ class PUIDManager(QtCore.QObject):
self.__puids[puid] = (self.__puids.get(puid, (None, None))[0], trackid)
self.__check_unsubmitted()
def remove(self, puid):
try: del self.__puids[puid]
except KeyError: pass
def __unsubmitted(self):
"""Return the count of unsubmitted PUIDs."""
for puid, (origtrackid, trackid) in self.__puids.iteritems():
@@ -66,7 +70,7 @@ class PUIDManager(QtCore.QObject):
self.tagger.window.set_statusbar_message(N_('PUIDs successfully submitted!'), timeout=3000)
for puid in puids.values():
try:
self.__puids[puid] = (self.__puids[puid][0], self.__puids[puid][0])
self.__puids[puid] = (self.__puids[puid][1], self.__puids[puid][1])
except KeyError:
pass
self.__check_unsubmitted()