diff options
author | Benjamin Saller <bcsaller@objectrealms.net> | 2007-07-30 20:47:38 (GMT) |
---|---|---|
committer | Benjamin Saller <bcsaller@objectrealms.net> | 2007-07-30 20:47:38 (GMT) |
commit | 6a90ec6c94beee949fb847513d4b72d382127dd2 (patch) | |
tree | 2f7f099abd4209aca586062f1475f084ce33b973 /src | |
parent | dfefc1f8623611f5ce2615a62679f349f7428f75 (diff) |
fix #2559
Diffstat (limited to 'src')
-rw-r--r-- | src/olpc/datastore/backingstore.py | 19 | ||||
-rw-r--r-- | src/olpc/datastore/model.py | 2 | ||||
-rw-r--r-- | src/olpc/datastore/xapianindex.py | 4 |
3 files changed, 18 insertions, 7 deletions
diff --git a/src/olpc/datastore/backingstore.py b/src/olpc/datastore/backingstore.py index 57bd787..724e7cc 100644 --- a/src/olpc/datastore/backingstore.py +++ b/src/olpc/datastore/backingstore.py @@ -339,6 +339,7 @@ class FileBackingStore(BackingStore): return content def _writeContent(self, uid, filelike, replace=True, target=None): + content = None if target: path = target else: path = self._translatePath(uid) @@ -359,9 +360,10 @@ class FileBackingStore(BackingStore): fp.close() else: bin_copy.bin_copy(filelike.name, path) - if verify: - content = self.indexmanager.get(uid) - content.checksum = c.hexdigest() +## if verify: +## if not content: +## content = self.indexmanager.get(uid) +## content.checksum = c.hexdigest() def _checksum(self, filename): c = sha.sha() @@ -538,7 +540,7 @@ class InplaceFileBackingStore(FileBackingStore): def create(self, props, filelike): # the file would have already been changed inplace # don't touch it - uid = self.indexmanager.index(props, filelike) + proposed_name = None if filelike: if isinstance(filelike, basestring): # lets treat it as a filename @@ -551,9 +553,14 @@ class InplaceFileBackingStore(FileBackingStore): proposed_name = props.get('filename', None) if not proposed_name: proposed_name = os.path.split(filelike.name)[1] + # record the name before qualifying it to the store + props['filename'] = proposed_name proposed_name = os.path.join(self.uri, proposed_name) - if not os.path.exists(proposed_name): - self._writeContent(uid, filelike, replace=False, target=proposed_name) + + uid = self.indexmanager.index(props, filelike) + + if proposed_name and not os.path.exists(proposed_name): + self._writeContent(uid, filelike, replace=False, target=proposed_name) return uid diff --git a/src/olpc/datastore/model.py b/src/olpc/datastore/model.py index a867c2f..14bb4b9 100644 --- a/src/olpc/datastore/model.py +++ b/src/olpc/datastore/model.py @@ -240,6 +240,8 @@ class Content(object): mt = self.get_property('mime_type', None) if mt: ext = mimetypes.guess_extension(mt) + # .ksh is a strange ext for plain text + if ext and ext == '.ksh': ext = '.txt' if ext: return None, ext return None, None diff --git a/src/olpc/datastore/xapianindex.py b/src/olpc/datastore/xapianindex.py index ce09c62..d46e0c7 100644 --- a/src/olpc/datastore/xapianindex.py +++ b/src/olpc/datastore/xapianindex.py @@ -183,8 +183,10 @@ class IndexManager(object): # done in the thread to keep things async and # latency lower. # we know that there is filestuff or it - # wouldn't have been queued + # wouldn't have been queued filename, mimetype = filestuff + if isinstance(filename, file): + filename = filename.name fp = converter(filename, mimetype) if fp: # read in at a fixed block size, try to |