Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

deleting should work now

  • Loading branch information...
commit 0de608e2f6c8c9811f722811c9342dd207477dc5 1 parent 9d60063
@geier authored
View
2  pycarddav/carddav.py
@@ -204,7 +204,7 @@ def delete_vcard(self, vref, etag):
if etag is None:
headers = ["Content-Type: text/vcard"]
else:
- headers = ["If-Match: %s" % etag, "Content-Type: text/vcard"]
+ headers = ["If-Match: " + str(etag), "Content-Type: text/vcard"]
self.curl.setopt(pycurl.HTTPHEADER, headers)
self.curl.setopt(pycurl.CUSTOMREQUEST, 'DELETE')
self.curl.setopt(pycurl.URL, remotepath)
View
4 pycarddav/pc_query.py
@@ -163,8 +163,8 @@ def main():
sys.exit('Found no matching cards.')
my_query.mark_for_deletion(href, '')
my_query.delete_vcard_from_db(href)
- print 'vcard %s deleted from local db, will be deleted on the ',
- 'server on the next sync'
+ print 'vcard %s deleted from local db, will be deleted on the ' + \
+ 'server on the next sync' %href
sys.exit()
View
18 pycarddav/pycard.py
@@ -634,9 +634,10 @@ def _make_tables(self):
conn.commit()
# create delete table
try:
- cursor.execute('''CREATE TABLE delete (
+ cursor.execute('''CREATE TABLE deleted (
href TEXT NOT NULL,
etag TEXT)''')
+ logging.debug("created deleted table")
except sqlite3.OperationalError as detail:
logging.debug("%s", detail)
except Exception, error:
@@ -797,7 +798,20 @@ def mark_for_deletion(self, vref, etag):
conn = sqlite3.connect(self.db_path)
cursor = conn.cursor()
stuple = (vref, '' )
- cursor.execute('INSERT INTO delete (href, etag) VALUES (?,?);', stuple)
+ cursor.execute('INSERT INTO deleted (href, etag) VALUES (?,?);',
+ stuple)
+ conn.commit()
+ cursor.close()
+
+ def rm_from_deleted(self, href):
+ """
+ removes href entry from deleted table, to be called after href
+ deleted from remote server
+ """
+ conn = sqlite3.connect(self.db_path)
+ cursor = conn.cursor()
+ stuple = (href, '')
+ cursor.execute('DELETE from deleted WHERE href=(?);', stuple)
conn.commit()
cursor.close()
View
1  pycarddav/pycardsyncer.py
@@ -164,6 +164,7 @@ def main():
for href, etag in hrefs_etags:
logging.info('trying to delete card %s', href)
syncer.delete_vcard(href, etag)
+ my_dbtool.rm_from_deleted(href)
if __name__ == "__main__":
Please sign in to comment.
Something went wrong with that request. Please try again.