#5707 BLOC Update.: Previews are not deleted when their matching datastore objects are removed
Zarro Boogs per Child
bugtracker at laptop.org
Thu Jan 3 07:06:58 EST 2008
#5707: Previews are not deleted when their matching datastore objects are removed
------------------------+---------------------------------------------------
Reporter: Phil | Owner: tomeu
Type: defect | Status: new
Priority: blocker | Milestone: Update.1
Component: datastore | Version: Build 650
Resolution: | Keywords: review?
Verified: 0 | Blocking:
Blockedby: |
------------------------+---------------------------------------------------
Comment(by tomeu):
Replying to [comment:6 Phil]:
> Unfortunately, Tomue, the patch you posted there (for my script, not the
Sugar one) doesn't quite work for me. I had to change the name of a local
variable called 'datastore', which I fixed (and pushed to Git), but even
after that the searches always return zero objects. This is in my sugar-
jhbuild instance. Not sure what's going on there.
Looks like at some point we regressed and cannot query by uid anymore.
Please try this other approach. I'm sorry but I don't have much time right
now so I cannot test it myself.
{{{
diff --git a/purge-previews b/purge-previews
index edbb90c..1587033 100755
--- a/purge-previews
+++ b/purge-previews
@@ -35,6 +35,8 @@ import os
import os.path
import sys
+from sugar.datastore import datastore
+
# Note that DATASTORE_PATH should almost certainly not be hardcoded, but
as
# no one Sugar-related was available at the time of coding this, I'm
running
# with it. Improvements welcome.
@@ -129,8 +131,12 @@ def purge_previews(datastore, pretend, verbose):
sys.stdout.write("Handling preview file: %s\n" % preview_file)
# Check to see if it has a partner-in-crime in the datastore.
- potential_datastore_file = os.path.join(datastore_dir,
preview_file)
- if os.path.isfile(potential_datastore_file):
+ uid = preview_file # Preview files are named following the uid of
the object.
+ try:
+ obj = datastore.get(uid)
+ except:
+ obj = None
+ if obj is not None:
if verbose:
sys.stdout.write(" It has a matching datastore file;
skipping.\n")
continue
}}}
--
Ticket URL: <http://dev.laptop.org/ticket/5707#comment:7>
One Laptop Per Child <http://dev.laptop.org>
OLPC bug tracking system
More information about the Bugs
mailing list