Apply @ndl's patches
The patches fix the issue where syncing across different profiles will always trigger a full sync if there's any change in either of the profiles.
This commit is contained in:
		
							parent
							
								
									1678890d3d
								
							
						
					
					
						commit
						c398ccdb89
					
				
							
								
								
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					[submodule "anki-bundled"]
 | 
				
			||||||
 | 
						path = anki-bundled
 | 
				
			||||||
 | 
						url = https://github.com/dae/anki.git
 | 
				
			||||||
							
								
								
									
										15
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								README.md
									
									
									
									
									
								
							@ -23,20 +23,9 @@ install some of the dependencies we need there:
 | 
				
			|||||||
        $ virtualenv ankisyncd.env
 | 
					        $ virtualenv ankisyncd.env
 | 
				
			||||||
        $ ankisyncd.env/bin/easy_install webob simplejson eventlet
 | 
					        $ ankisyncd.env/bin/easy_install webob simplejson eventlet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
3. Download and install libanki.  You can find the latest release of Anki here:
 | 
					3. Patch the bundled libanki:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    http://code.google.com/p/anki/downloads/list
 | 
						$ ./patch_libanki.sh
 | 
				
			||||||
 | 
					 | 
				
			||||||
    Look for a *.tgz file with a Summary of "Anki Source".  At the time of this
 | 
					 | 
				
			||||||
    writing that is anki-2.0.11.tgz.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Download this file and extract.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Then either:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    a. Run ```make install```, or
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    b. Copy the entire directory to /usr/share/anki
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
4. Copy the example.ini to production.ini and edit for your needs. Warning: If
 | 
					4. Copy the example.ini to production.ini and edit for your needs. Warning: If
 | 
				
			||||||
   you disable SSL, login credentials will be transported in plain text!
 | 
					   you disable SSL, login credentials will be transported in plain text!
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								anki-bundled
									
									
									
									
									
										Submodule
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										1
									
								
								anki-bundled
									
									
									
									
									
										Submodule
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					Subproject commit 499b02281b4ab2bea3c4167128f02cc3d9cf973b
 | 
				
			||||||
@ -59,7 +59,7 @@ class CollectionWrapper(object):
 | 
				
			|||||||
            else:
 | 
					            else:
 | 
				
			||||||
                raise
 | 
					                raise
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        col = anki.storage.Collection(self.path)
 | 
					        col = anki.storage.Collection(self.path, server=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Do any special setup
 | 
					        # Do any special setup
 | 
				
			||||||
        if self.setup_new_collection is not None:
 | 
					        if self.setup_new_collection is not None:
 | 
				
			||||||
@ -71,7 +71,7 @@ class CollectionWrapper(object):
 | 
				
			|||||||
        """Open the collection, or create it if it doesn't exist."""
 | 
					        """Open the collection, or create it if it doesn't exist."""
 | 
				
			||||||
        if self.__col is None:
 | 
					        if self.__col is None:
 | 
				
			||||||
            if os.path.exists(self.path):
 | 
					            if os.path.exists(self.path):
 | 
				
			||||||
                self.__col = anki.storage.Collection(self.path)
 | 
					                self.__col = anki.storage.Collection(self.path, server=True)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                self.__col = self.__create_collection()
 | 
					                self.__col = self.__create_collection()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -425,6 +425,7 @@ class SyncApp(object):
 | 
				
			|||||||
                fd.write(data)
 | 
					                fd.write(data)
 | 
				
			||||||
        finally:
 | 
					        finally:
 | 
				
			||||||
            col.reopen()
 | 
					            col.reopen()
 | 
				
			||||||
 | 
					            col.load()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # run hook_upload if one is defined
 | 
					        # run hook_upload if one is defined
 | 
				
			||||||
        if self.hook_upload is not None:
 | 
					        if self.hook_upload is not None:
 | 
				
			||||||
@ -442,6 +443,7 @@ class SyncApp(object):
 | 
				
			|||||||
            data = open(session.get_collection_path(), 'rb').read()
 | 
					            data = open(session.get_collection_path(), 'rb').read()
 | 
				
			||||||
        finally:
 | 
					        finally:
 | 
				
			||||||
            col.reopen()
 | 
					            col.reopen()
 | 
				
			||||||
 | 
					            col.load()
 | 
				
			||||||
        return data
 | 
					        return data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @wsgify
 | 
					    @wsgify
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										46
									
								
								libanki.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								libanki.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					diff -urN anki/collection.py anki/collection.py
 | 
				
			||||||
 | 
					--- anki/collection.py	2016-10-22 00:04:43.365953912 +0200
 | 
				
			||||||
 | 
					+++ anki/collection.py	2016-10-23 10:46:26.171300370 +0200
 | 
				
			||||||
 | 
					@@ -60,7 +60,7 @@
 | 
				
			||||||
 | 
					         self.server = server
 | 
				
			||||||
 | 
					         self._lastSave = time.time()
 | 
				
			||||||
 | 
					         self.clearUndo()
 | 
				
			||||||
 | 
					-        self.media = MediaManager(self, server)
 | 
				
			||||||
 | 
					+        self.media = MediaManager(self)
 | 
				
			||||||
 | 
					         self.models = ModelManager(self)
 | 
				
			||||||
 | 
					         self.decks = DeckManager(self)
 | 
				
			||||||
 | 
					         self.tags = TagManager(self)
 | 
				
			||||||
 | 
					diff -urN anki/media.py anki/media.py
 | 
				
			||||||
 | 
					--- anki/media.py	2016-10-22 00:04:43.367953863 +0200
 | 
				
			||||||
 | 
					+++ anki/media.py	2016-10-23 10:46:16.947524341 +0200
 | 
				
			||||||
 | 
					@@ -26,11 +26,8 @@
 | 
				
			||||||
 | 
					     ]
 | 
				
			||||||
 | 
					     regexps = soundRegexps + imgRegexps
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-    def __init__(self, col, server):
 | 
				
			||||||
 | 
					+    def __init__(self, col):
 | 
				
			||||||
 | 
					         self.col = col
 | 
				
			||||||
 | 
					-        if server:
 | 
				
			||||||
 | 
					-            self._dir = None
 | 
				
			||||||
 | 
					-            return
 | 
				
			||||||
 | 
					         # media directory
 | 
				
			||||||
 | 
					         self._dir = re.sub("(?i)\.(anki2)$", ".media", self.col.path)
 | 
				
			||||||
 | 
					         # convert dir to unicode if it's not already
 | 
				
			||||||
 | 
					@@ -51,8 +48,6 @@
 | 
				
			||||||
 | 
					         self.connect()
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					     def connect(self):
 | 
				
			||||||
 | 
					-        if self.col.server:
 | 
				
			||||||
 | 
					-            return
 | 
				
			||||||
 | 
					         path = self.dir()+".db2"
 | 
				
			||||||
 | 
					         create = not os.path.exists(path)
 | 
				
			||||||
 | 
					         os.chdir(self._dir)
 | 
				
			||||||
 | 
					@@ -103,8 +98,6 @@
 | 
				
			||||||
 | 
					             os.rename("../collection.media.db", npath)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					     def close(self):
 | 
				
			||||||
 | 
					-        if self.col.server:
 | 
				
			||||||
 | 
					-            return
 | 
				
			||||||
 | 
					         self.db.close()
 | 
				
			||||||
 | 
					         self.db = None
 | 
				
			||||||
 | 
					         # change cwd back to old location
 | 
				
			||||||
							
								
								
									
										3
									
								
								patch_libanki.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										3
									
								
								patch_libanki.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					cd "$(dirname ${BASH_SOURCE[0]})/anki-bundled"
 | 
				
			||||||
 | 
					patch -p0 < ../libanki.patch
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user