rename also rename notes

main
Fabien Benureau 11 years ago
parent 1ad64d7859
commit 29897cc0ad

@ -65,11 +65,17 @@ class DataBroker(object):
def real_docpath(self, docpath):
return self.docbroker.real_docpath(docpath)
# notesbroker
def in_notesdir(self, docpath):
return self.notebroker.in_docsdir(docpath)
def copy_note(self, citekey, source_path, overwrite=False):
return self.notebroker.copy_doc(citekey, source_path, overwrite=overwrite)
def remove_note(self, docpath, silent=True):
return self.notebroker.remove_doc(docpath, silent=silent)
def real_notepath(self, docpath):
return self.notebroker.real_docpath(docpath)

@ -79,6 +79,12 @@ class DataCache(object):
def in_notesdir(self, docpath):
return self.databroker.in_notesdir(docpath)
def copy_note(self, citekey, source_path, overwrite=False):
return self.databroker.copy_note(citekey, source_path, overwrite=overwrite)
def remove_note(self, docpath, silent=True):
return self.databroker.remove_note(docpath, silent=silent)
def real_notepath(self, docpath):
return self.databroker.real_notepath(docpath)

@ -126,6 +126,9 @@ class DocBroker(object):
return False
return parsed.scheme == self.scheme
# def doc_exists(self, citekey, ext='.txt'):
# return check_file(os.path.join(self.docdir, citekey + ext), fail=False)
def copy_doc(self, citekey, source_path, overwrite=False):
""" Copy a document to the pubsdir/doc, and return the location

@ -114,6 +114,14 @@ class Repository(object):
self.databroker.remove_doc(paper.docpath)
paper.docpath = new_docpath
try:
old_notepath = 'notesdir://{}.txt'.format(old_citekey)
new_notepath = self.databroker.copy_note(new_citekey, old_notepath)
self.databroker.remove_notei(old_notepath)
except IOError:
import traceback
traceback.print_exc()
# push_paper to new_citekey
paper.citekey = new_citekey
self.push_paper(paper, event=False)

Loading…
Cancel
Save