I'm switching some storage from chrome.storage.sync over to chrome.syncFileSystem for size reasons, and I'm having a little trouble getting it to work. I can successfully request the filesystem, but once I have it, the following call fails with an Encoding Error, which the HTML5 filesystem API docs say means that the path was invalid.fs.root.getFile("test.txt", {create: true}, gotFile, gotError);
The documentation for syncFileSystem, and the sample code, seems to have fallen a bit behind, and examples are thin on the ground. Is there some different way I need to pass the path in so that it won't be rejected, or do I have another problem?
--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-app...@chromium.org.
To post to this group, send email to chromi...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/.
For more options, visit https://groups.google.com/a/chromium.org/groups/opt_out.
Hi,On Tue, Dec 3, 2013 at 4:56 PM, Thomas Wilburn <sombrad...@gmail.com> wrote:
I'm switching some storage from chrome.storage.sync over to chrome.syncFileSystem for size reasons, and I'm having a little trouble getting it to work. I can successfully request the filesystem, but once I have it, the following call fails with an Encoding Error, which the HTML5 filesystem API docs say means that the path was invalid.fs.root.getFile("test.txt", {create: true}, gotFile, gotError);Does the problem always happen? Would you be able to try relaunching Chrome and see if it still happens? I think I've seen similar error before but I couldn't repro after relaunching.The documentation for syncFileSystem, and the sample code, seems to have fallen a bit behind, and examples are thin on the ground. Is there some different way I need to pass the path in so that it won't be rejected, or do I have another problem?Your code looks fine to me. I've tested the following code snippet (which must be mostly same as yours) and it worked fine for me (and the file's successfully sync'ed):var filesystem, entry;chrome.syncFileSystem.requestFileSystem(function(fs) { filesystem = fs; });
filesystem.root.getFile("test.txt", {create:true}, function(e) { entry = e }, function(e) { console.log(e) });
Okay, having fought with this for a while today, I have some additional questions:1) Currently, it looks like the first time this is called, if the device is not online the call will fail to get a file system, returning null and a "File Error -1." on chrome.runtime.lastError. Setting aside the fact that it's an extremely undescriptive error message, this is fine for now, because I'm calling it from inside a chrome.runtime.onInstalled listener, and I can assume that the user was online in order to install. Longer-term, that won't be the case--people may not actually start the app right after installing it, so they may lose connectivity. Is it possible to get a filesystem right away, whether or not the device has connectivity?
2) I'm still seeing some weird errors with users when I try to roll this out just for backups, to the point where I'm not entirely comfortable relying on it for actual functionality. It seems like on some machines, across multiple operating systems, the callbacks aren't ever actually called for requestFileSystem, and I'm not sure why. I didn't have time to check on chrome://syncfs-internals, so I'll try to get more information. Are you aware of any caveats I should watch out for when using these APIs, or that might be causing the callback to fail to fire?
Thanks, that's very helpful. If I can, I'll try to get access to the syncfs-internals logs tomorrow on the machine where I can reproduce the callback failure, but I've already removed the code from the web store so it may be a bit of a race to beat the update.
I can understand where creating a detached file system might be confusing, but it would be nice to have a way to handle this more directly, or a way that I can test for that state and handle it (perhaps by re-requesting when the network is available). I'm trying to write for "offline first," and if I can't rely on syncFileSystem to work regardless of connection state in the first call, it's probably going to be impossible to use because there's no viable fallback (short of opening an HTML5 filesystem and manually doing the caching/transfer to Drive at a later time, which is not a road I really want to explore).