From e53f4190a4b1aa1c40b16b194520b2d0cadc4aa9 Mon Sep 17 00:00:00 2001 From: Benjamin Saller Date: Mon, 30 Jul 2007 21:25:10 +0000 Subject: Merge branch 'master' into version_prototype --- diff --git a/NEWS b/NEWS index bcc3499..dcad2ee 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +Snapshot 4a4283978f + +* More usb devices fixes. (bcsaller) + Snapshot d0bcbf67d1 * Some more fixes for usb devices. (bcsaller) diff --git a/README.txt b/README.txt index d33bc11..d2901d8 100644 --- a/README.txt +++ b/README.txt @@ -37,7 +37,6 @@ Converters ---------- (used to index binaries) -odt2txt http://stosberg.net/odt2txt/ pdftotext from poppler-utils abiword/write 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/converter.py b/src/olpc/datastore/converter.py index e5baf47..75f7568 100644 --- a/src/olpc/datastore/converter.py +++ b/src/olpc/datastore/converter.py @@ -160,7 +160,6 @@ converter.registerConverter('.doc', doctotext) converter.registerConverter('application/msword', doctotext) # ODT -odt2txt = subprocessconverter('/usr/bin/odt2txt --encoding=UTF-8 --output=%(target)s %(source)s') -converter.registerConverter('.odt', odt2txt) -converter.registerConverter('application/vnd.oasis.opendocument.text', odt2txt) +converter.registerConverter('.odt', doctotext) +converter.registerConverter('application/vnd.oasis.opendocument.text', doctotext) 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 -- cgit v0.9.1