~ubuntu-branches/debian/sid/calibre/sid

« back to all changes in this revision

Viewing changes to src/calibre/db/restore.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-05-14 18:17:50 UTC
  • mfrom: (1.5.10)
  • Revision ID: package-import@ubuntu.com-20140514181750-xyrxqa47dbw0qfhu
Tags: 1.36.0+dfsg-1
* New upstream release:
  - Fixes editing of metadata (Closes: #741638)

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
6
6
__docformat__ = 'restructuredtext en'
7
7
 
8
 
import re, os, traceback, shutil
 
8
import re, os, traceback, shutil, time
9
9
from threading import Thread
10
10
from operator import itemgetter
11
11
 
269
269
        save_path = self.olddb = os.path.splitext(dbpath)[0]+'_pre_restore.db'
270
270
        if os.path.exists(save_path):
271
271
            os.remove(save_path)
272
 
        os.rename(dbpath, save_path)
 
272
        try:
 
273
            os.rename(dbpath, save_path)
 
274
        except OSError as err:
 
275
            if getattr(err, 'winerror', None) == 32:  # ERROR_SHARING_VIOLATION
 
276
                time.sleep(4)  # Wait a little for dropbox or the antivirus or whatever to release the file
 
277
                os.rename(dbpath, save_path)
 
278
            else:
 
279
                raise
273
280
        shutil.copyfile(ndbpath, dbpath)
274
281
 
275
282