11-27-2011 10:23 PM - edited 11-27-2011 10:37 PM
I've just had a problem report regarding an odd issue that is associated with the latest updates.
Battery Guru can write export files (in CSV format) to shared/documents/BatteryGuru. The files are simple text files created with code basically like this:
stream = new FileStream();
stream.openAsync(temp_path, FileMode.WRITE);
# later on in an event handler
stream.writeUTFBytes(...)
# later on in another event handler
stream.close();
The catch is that the files are initially created inside the app's tmp/ folder in the sandbox, and only after they are completely written are they moved to shared/documents/BatteryGuru, with a "temp_path.moveTo(dest, true);"
Under previous versions this worked fine, and files came out looking like this (as seen by "ls -l" via SSH):
-rwxrw---- 1 nobody 1000_shared 3020833 Nov 11 20:25 export-20110720T142136-20110909T235450.csv
These files were visible from the MEDIA network share and could be copied off the PlayBook. They could also be moved around, renamed, etc, just like any other file created in the shared/ folders in the first place.
Under the latest updates, 1.0.8.4985 and 2.0.0.4869, things have changed. Here's what "ls -l" sees on the 1.0.8 unit:
-rw-rw---- 1 100441000 10044 969073 Nov 27 20:21 export-20111110T183253-20111127T202119.csv
On my 2.0.0.4869 unit, here's a similar case:
-rw-rw---- 1 100591000 10059 326405 Nov 27 21:57 export-20111123T185137-20111127T215640.csv
The problem is that these files cannot be read from the MEDIA share, nor in fact are even listed in a directory listing when viewed from there. They cannot be copied, they cannot be opened, except perhaps by the app that wrote them. (I can't check that yet since Battery Guru does not read back its own export files.. I'd have to make a test build to check that.)
When another AIR app (e.g. Files & Folders) attempts to read the file, it reports a 3001 error which means this "File or directory access denied."
When I try it from SSH, I get this:
$ cp export-20111110T183253-20111127T202119.csv ../tempfile cp: Can't open source file. (export-20111110T183253-20111127T202119.csv): Permission denied
I'm not actually sure the problem is related to my initially writing to tmp/ though. The BatteryGuru/ folder itself is created automatically if it doesn't exist. On my 1.0.8 unit the folder already existed from before, so it looks like this:
drwxrws--- 2 nobody 1000_shared 4096 Nov 27 20:21 BatteryGuru
Under 2.0, where I just did an export for the first time, the new BatteryGuru folder looks like this:
drwxrws--- 2 100591000 1000_shared 4096 Nov 27 21:57 BatteryGuru
I can see that other apps may be affected in a similar fashion, though the basic inability to read the files at all may not be affecting them for some reason... maybe because they aren't writing to a subfolder? Here are two files, one written by the Box.net app, the other by the "native" DocumentsToGo app, for the updated OS, and the earlier one:
# newly written since update to 1.0.8.4985: -rw-rw-r-- 1 100491000 1000_shared 2016327 Nov 10 21:17 AT32UC3C Series Summary.pdf -rw-rw-r-- 1 100121000 1000_shared 19968 Nov 16 18:56 BBX Python Todos.doc # written by 1.0.7: -rwxrw---- 1 nobody 1000_shared 111705 Nov 11 20:24 GUGO.pdf -rwxrw---- 1 nobody 1000_shared 12288 Nov 11 20:24 Todo items.doc
Anyone else experiencing an actual problem reading files written by their app to the shared folders?
In particular, could anyone whose app writes to its own subfolder, created in the shared/ folder tree, please check and see whether under the updated OS version(s) they have any issue like mine, where the file is inaccessible though shows in a local directory listing but is invisible when viewed via Samba?
11-27-2011 10:38 PM
11-27-2011 11:31 PM
peter9477 wrote:Anyone else experiencing an actual problem reading files written by their app to the shared folders?
In particular, could anyone whose app writes to its own subfolder, created in the shared/ folder tree, please check and see whether under the updated OS version(s) they have any issue like mine, where the file is inaccessible though shows in a local directory listing but is invisible when viewed via Samba?
Files & Folders creates /accounts/1000/shared/downloads/Dropbox and writes there when you use the "Download and open" function. You can also do it manually of course. No problems reading that back or accessing it via Wifi with 2.0.0.4869. Also no problem accessing pre-existing folders after an upgrade from 1.07 to 2.0.
Difference is that F&F writes directly to the folder, it doesn't write to ./tmp first and then move the file, as you describe...
11-28-2011 12:35 AM
11-28-2011 01:12 AM
I've found what looks like it may be a viable workaround, though it's imperfect.
My app can initially create a fresh folder in shared/documents. That gives the folder set-group-id (the "s" bit in the permission field) and a group of 1000_shared.
The folder is then moved to the tmp/ folder in the sandbox as, say, tmp/magicfolder.
The export file is generated into the tmp/magicfolder location, where because of the set-group-id bit it magically acquires group 1000_shared instead of the app's own group.
The export file is renamed to appear under the shared/documents/BatteryGuru location.
The only difference between this and what it looks like if you create the file initially in that location is that it has "world" read and write permissions. Normally the files have only rw-rw---- but this one has rw-rw-rw-. Doesn't seem like it would be a concern.
11-28-2011 10:19 AM
peter9477 wrote:
My use case with this copy-from-tmp thing was to prevent the user accidentally accessing a partially-written export file.
Perfectly valid use case IMO. Could you use an ANE to adjust the privs before moving the file...?
11-28-2011 11:40 AM