Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/olpc/datastore/backingstore.py
diff options
context:
space:
mode:
authorBenjamin Saller <bcsaller@objectrealms.net>2007-07-20 10:09:31 (GMT)
committer Benjamin Saller <bcsaller@objectrealms.net>2007-07-20 10:09:31 (GMT)
commit720c077dba3eb0944318cc0410d4a2df9880a305 (patch)
tree51c92bed8c18529f4c3609a6504868726b766ff5 /src/olpc/datastore/backingstore.py
parent9aabdfb24b3d03dae3835bf29f8be005fa9ccab2 (diff)
handle find(dict(query : 'title:foo mimetype:text/plain'))
where query is the string arg accepted by xapianindex::search use the system binary for copies, its already optimized use gnomevfs in converter as well as importer sorting on non-existant properties shouldn't throw errors sorting on dates verified
Diffstat (limited to 'src/olpc/datastore/backingstore.py')
-rw-r--r--src/olpc/datastore/backingstore.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/olpc/datastore/backingstore.py b/src/olpc/datastore/backingstore.py
index a7a51ca..b5b93f9 100644
--- a/src/olpc/datastore/backingstore.py
+++ b/src/olpc/datastore/backingstore.py
@@ -11,14 +11,15 @@ __copyright__ = 'Copyright ObjectRealms, LLC, 2007'
__license__ = 'The GNU Public License V2+'
import cPickle as pickle
-import sha
+import gnomevfs
import os
import re
-import shutil
+import sha
import subprocess
import time
from olpc.datastore.xapianindex import IndexManager
+from olpc.datastore import bin_copy
from olpc.datastore import utils
# changing this pattern impacts _targetFile
@@ -312,7 +313,7 @@ class FileBackingStore(BackingStore):
fp.write(line)
fp.close()
else:
- shutil.copyfile(filelike.name, path)
+ bin_copy.bin_copy(filelike.name, path)
if verify:
content = self.indexmanager.get(uid)
content.checksum = c.hexdigest()
@@ -438,9 +439,10 @@ class InplaceFileBackingStore(FileBackingStore):
relative = source[len(self.uri)+1:]
result, count = self.indexmanager.search(dict(filename=relative))
+ mime_type = gnomevfs.get_mime_type(source)
if not count:
# create a new record
- self.create(dict(filename=relative), source)
+ self.create(dict(filename=relative, mime_type=mime_type), source)
else:
# update the object with the new content iif the
# checksum is different
@@ -451,7 +453,7 @@ class InplaceFileBackingStore(FileBackingStore):
# only if the checksum is different
#checksum = self._checksum(source)
#if checksum != content.checksum:
- self.update(uid, dict(filename=relative), source)
+ self.update(uid, dict(filename=relative, mime_type=mime_type), source)
if self.options.get('sync_mount', False):
self.complete_indexing()