dsnopek / anki-sync-server

A personal Anki sync server (so you can sync against your own server rather than AnkiWeb)
GNU Affero General Public License v3.0
741 stars 95 forks source link

Got "WindowsError: [Error 183] " while running it on Paython27/Win7 #44

Open ninja33 opened 8 years ago

ninja33 commented 8 years ago

hi team: I installed this package (2.0.6) by using easy_install, I successfully logon as username "test" in anki windows client, and anki client prompt me to upload/download all deck info for first time sync, I choose upload. then I got some errors in console.

seems something happened after checking log file

in operation_upload
os.rename(temp_db_path, session.get_collection_path())
WindowsError: [Error 183]

WindowsError: [Error 183] in python usually means you just can not rename that file because it already exists.

ninja33 commented 8 years ago

emm, I think I got the solution. in python document 15.1. os — Miscellaneous operating system interfaces, it mentioned.

os.rename(src, dst) Rename the file or directory src to dst. If dst is a directory, OSError will be raised. On Unix, if dst exists and is a file, it will be replaced silently if the user has permission. The operation may fail on some Unix flavors if src and dst are on different filesystems. If successful, the renaming will be an atomic operation (this is a POSIX requirement). On Windows, if dst already exists, OSError will be raised even if it is a file; there may be no way to implement an atomic rename when dst names an existing file.

so, in windows environment, a quick fix could be remove prior to the rename in sync_app.py line 471

        # Overwrite existing db.
        col.close()
        try:
            if os.name == 'nt':
                os.remove(session.get_collection_path())
            os.rename(temp_db_path, session.get_collection_path())
        finally:
            col.reopen()

it's well done, no more error message :smile:

bosbyj commented 7 years ago

Great job! It is working on my win8 platform.

gabriellluz commented 7 years ago

Your fix worked for me, too!! Thank you.