Upload current progress
This commit is contained in:
51
force_sync.py
Executable file
51
force_sync.py
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Force Obsidian LiveSync to re-sync by touching all documents
|
||||
This updates mtime to trigger the _changes feed
|
||||
"""
|
||||
import couchdb
|
||||
import time
|
||||
from urllib.parse import quote
|
||||
|
||||
USER = "admin"
|
||||
PASSWORD = "DonCucarach0!?"
|
||||
IP_ADDRESS = "100.100.112.48"
|
||||
PORT = "5984"
|
||||
DB_NAME = "obsidiandb"
|
||||
|
||||
def force_sync():
|
||||
safe_password = quote(PASSWORD, safe="")
|
||||
safe_username = quote(USER, safe="")
|
||||
url = f"http://{safe_username}:{safe_password}@{IP_ADDRESS}:{PORT}/"
|
||||
|
||||
server = couchdb.Server(url)
|
||||
db = server[DB_NAME]
|
||||
|
||||
print("Force syncing all files by updating mtime...")
|
||||
|
||||
current_time = int(time.time() * 1000)
|
||||
count = 0
|
||||
|
||||
for row in db.view('_all_docs', include_docs=True):
|
||||
doc = row.doc
|
||||
|
||||
# Only update file metadata docs
|
||||
if 'children' in doc and isinstance(doc.get('children'), list):
|
||||
path = doc.get('path', doc['_id'])
|
||||
|
||||
# Update mtime to current time to trigger sync
|
||||
doc['mtime'] = current_time
|
||||
|
||||
try:
|
||||
db.save(doc)
|
||||
count += 1
|
||||
print(f"✓ {path}")
|
||||
time.sleep(2) # Rate limit: 2 seconds between updates
|
||||
except Exception as e:
|
||||
print(f"✗ {path}: {e}")
|
||||
|
||||
print(f"\nUpdated {count} files. Obsidian should now re-sync.")
|
||||
print("Check your Obsidian sync plugin - it should detect changes now.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
force_sync()
|
||||
Reference in New Issue
Block a user