-
Notifications
You must be signed in to change notification settings - Fork 1.7k
webkitRequestFileSystem.getFile returns NOT_FOUND_ERR #4549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This comment was originally written by [email protected] I think the gist of the bug is that when you pass an object as an argument to a native function, you sometimes have to make sure that that object is a "plain old JavaScript object". I say sometimes, because it depends on the function. If the function is part of a container class of sometime, it would make sense for you to be able to get back the Dart object that you gave the container object. However, in this case, the function is an HTML5 function that needs a plain old JavaScript object. |
cc @rakudrama. |
This comment was originally written by [email protected] Extrapolating from the above comment, we're going to have to look at every parameter to every native JavaScript function to determine whether objects should be "unboxed" (i.e. translated to plain old JavaScript objects). |
This comment was originally written by [email protected] See also issue #3022. It may be the same bug. |
JJ - can you try this again? Unfortunately the one test we have in this area has lots of bugs of its own. |
This comment was originally written by [email protected] I'll work on this today. |
This comment was originally written by [email protected] I just tried the latest build, and it works in Dartium and dart2js! :-D I'm marking this as verified. Added Verified label. |
This issue was originally filed by [email protected]
I'm trying to port (http://www.html5rocks.com/en/tutorials/file/filesystem/) to Dart. Things work under Dartium, but they fail when compiling to JavaScript. I think I know why.
Here's the code:
import('dart:html');
import('dart:web');
// This example leads to NOT_FOUND_ERR when using dart2js, but not when using Dartium.
bool _handleError(FileError e) {
var msg = '';
switch (e.code) {
case FileError.QUOTA_EXCEEDED_ERR:
msg = 'QUOTA_EXCEEDED_ERR';
break;
case FileError.NOT_FOUND_ERR:
msg = 'NOT_FOUND_ERR';
break;
case FileError.SECURITY_ERR:
msg = 'SECURITY_ERR';
break;
case FileError.INVALID_MODIFICATION_ERR:
msg = 'INVALID_MODIFICATION_ERR';
break;
case FileError.INVALID_STATE_ERR:
msg = 'INVALID_STATE_ERR';
break;
default:
msg = 'Unknown Error';
break;
}
window.alert("Error: $msg");
return true;
}
void main() {
window.webkitRequestFileSystem(Window.TEMPORARY, 1024 * 1024, (filesystem) {
filesystem.root.getFile('log.txt', {"create": true}, null, _handleError);
}, _handleError);
}
Here is a snippet from the generated JavaScript:
$.$defineNativeClass('DirectoryEntry', [], {
getFile$4: function(path, flags, successCallback, errorCallback) {
return this.getFile(path,flags,$.convertDartClosureToJS(successCallback, 1),$.convertDartClosureToJS(errorCallback, 1));
}
});
"this" is a "DirectoryEntry". Hence, we're calling a native JavaScript function. At this point, flags should be a normal JavaScript object, {create: true}. It isn't. It's a LinkedHashMapImplementation. Because everything is an object in JavaScript, it tries to lookup "create" on that object, and it's not actually there. Hence, rather than trying to create the object, it tries to lookup an existing file with that name, and it's not found. That's why this leads to NOT_FOUND_ERR when trying to create the file.
I'm prioritizing this as high since it's blocking my HTML5 tutorial work and since it should be straightforward to fix :)
The text was updated successfully, but these errors were encountered: