Locking Files

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Posts: 412
Joined: Mon Aug 13, 2007 4:44 pm
Location: Sale UK / FL USA

Locking Files

Post by andyh1234 » Thu Oct 01, 2020 11:10 am

I am running into more and more of an issue with file sharing services corrupting files I write to using the database commands.

This is happening on Windows and Mac, basically I open the DB file, write and then close it, I don't leave it open. But sometimes when the database is opened again the system gets a revdberr malformed and when the user sends me a backup of their data files the database is corrupt. In evey case they are using some form of file backup sync, dropbox etc.

Is there a way in livecode to lock a file so these file sync services leave it alone until the file is unlocked or the app is closed etc?

VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8322
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles

Re: Locking Files

Post by FourthWorld » Thu Oct 01, 2020 5:54 pm

Dropbox and similar file syncing services are notorious for corrupting sqLite files. This is one of the better discussions on that:
https://forums.zotero.org/discussion/66 ... a-solution

I'm not sure that local file locking alone with solve the issue. Depending on how the syncing service handles that, it may just result is multiple "conflict" files, so the DB might be OK but then there's the new task of reconciling diffs between conflict copies.

Dropbox, Nextcloud, iCloud, and most others provide an API for use-cases not handled well with default syncing. That may be your best bet with this. I've been reading about this issue for many years across a wide range of apps, and I haven't yet come across any robust general solution other than recommendations to use the APIs.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”