You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "fancsali (via GitHub)" <gi...@apache.org> on 2026/03/22 16:20:06 UTC
[I] Directory read returns broken FileEntry objects [cordova-plugin-file]
fancsali opened a new issue, #653:
URL: https://github.com/apache/cordova-plugin-file/issues/653
# Bug Report
## Problem
### What is expected to happen?
I should be able to read a FileEntry's metadata no matter how I got hold of the object
### What does actually happen?
I retrieving the FileEntry handle directly via `resolveLocalFilesystemURL` I can call getMetadata() on the returned object without an issue; but if I obtain the handle by reading the parent (root) directory, the call will result in NOT_FOUND_ERR`
### Command or Code
<!-- What command or code is needed to reproduce the problem? -->
I am running the below code in the `deviceready` event handler:
```
console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
function errorHandler(e) {
console.error("Error: ", e);
}
function testFileMetadataRead() {
console.log("Successful file write...");
window.resolveLocalFileSystemURL(cordova.file.dataDirectory + "/test.txt", function(file) {
console.log("Contructor of FILE handle", file.constructor);
file.getMetadata(
function (m) { console.log("Getting FILE metadata", file, m) },
function (e) { console.log("Error getting FILE metadata", e) }
);
}, errorHandler);
window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function(dir) {
dir.createReader().readEntries(function (entries) {
entries.forEach(function(entry) {
console.log("Contructor of DIRECTORY ENTRY handle", entry.constructor);
entry.getMetadata(
function (m) { console.log("Getting DIR ENTRY metadata", file, m) },
function (e) { console.log("Error getting DIR ENTRY metadata", e) }
);
});
}, function (e) { console.log("Error listing directory", e) });
}, errorHandler);
}
window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function(dir) {
dir.getFile("test.txt", { create: true, exclusive: false }, function (fileEntry) {
fileEntry.createWriter(function (fileWriter) {
fileWriter.onwriteend = testFileMetadataRead;
fileWriter.onerror = function (e) { console.log("Error writing FILE", e) };
const blob = new Blob(["The quick brown fox jumps over the lazy dog!"], { type: 'text/plain' });
fileWriter.write(blob);
});
},
function (e) { console.log("Error creating new file", e) });
}, errorHandler);
```
## Result
```
Running cordova-browser@7.0.0 bundle.js:480:13
Successful file write... bundle.js:509:17
Contructor of FILE handle
function FileEntry(name, fullPath, fileSystem, nativeURL)
bundle.js:512:21
Getting FILE metadata
Object { isFile: true, isDirectory: false, name: "test.txt", fullPath: "/test.txt", filesystem: {…}, nativeURL: null }
Object { modificationTime: Date Sun Mar 22 2026 16:13:17 GMT+0000 (Greenwich Mean Time), size: 44 }
bundle.js:514:40
Contructor of DIRECTORY ENTRY handle
function FileEntry(name, fullPath, fileSystem, nativeURL)
bundle.js:522:29
Error getting DIR ENTRY metadata
Object { code: 1 }
bundle.js:525:48
```
### Environment, Platform, Device
<!-- In what environment, on what platform or on which device are you experiencing the issue? -->
Using Cordova Browser for testing on Linux Mint 22.3.
### Version information
<!--
What are relevant versions you are using?
For example:
Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
Other Frameworks: Ionic Framework and CLI version
Operating System, Android Studio, Xcode etc.
-->
cordova-browser@7.0.0
cordova-plugin-file@8.1.3
cordova-plugin-webpack@1.0.5
## Checklist
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] Directory read returns broken FileEntry objects [cordova-plugin-file]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on issue #653:
URL: https://github.com/apache/cordova-plugin-file/issues/653#issuecomment-4110680482
That's pretty odd:
> cordova.js:314 Uncaught ReferenceError: file is not defined
I assume that's a reference to `cordova.file` which kinda suggest that the plugin maybe didn't get installed right?
Are you able to share a sample reproduction project?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] Directory read returns broken FileEntry objects [cordova-plugin-file]
Posted by "fancsali (via GitHub)" <gi...@apache.org>.
fancsali commented on issue #653:
URL: https://github.com/apache/cordova-plugin-file/issues/653#issuecomment-4106709393
Well, being completely honest, my product would be truly cross platform...
... I'd like to have a lightweight browser version eventually.
For now, that's the test (and only) platform - just to make the development cycle short and sweet.
That being said, I built the app for Android, and it's even worse; the console says (using Chrome remote inspect/debug):
```
index.js:45 Successful file write...
index.js:48 Contructor of FILE handle ƒ (name, fullPath, fileSystem, nativeURL) {
// remove trailing slash if it is present
if (fullPath && /\/$/.test(fullPath)) {
fullPath = fullPath.substring(0, fullPath.length - 1);
…
index.js:50 Getting FILE metadata FileEntry Metadata
index.js:58 Contructor of DIRECTORY ENTRY handle ƒ (name, fullPath, fileSystem, nativeURL) {
// add trailing slash if it is missing
if ((fullPath) && !/\/$/.test(fullPath)) {
fullPath += '/';
}
// add trailing slash if it is m…
index.js:58 Contructor of DIRECTORY ENTRY handle ƒ (name, fullPath, fileSystem, nativeURL) {
// add trailing slash if it is missing
if ((fullPath) && !/\/$/.test(fullPath)) {
fullPath += '/';
}
// add trailing slash if it is m…
index.js:58 Contructor of DIRECTORY ENTRY handle ƒ (name, fullPath, fileSystem, nativeURL) {
// remove trailing slash if it is present
if (fullPath && /\/$/.test(fullPath)) {
fullPath = fullPath.substring(0, fullPath.length - 1);
…
cordova.js:314 Uncaught ReferenceError: file is not defined
at index.js:60:39
at success (Entry.js:73:9)
at Object.callbackFromNative (cordova.js:295:58)
at <anonymous>:1:9
```
The last message repeating several times, if I reload the app (i.e. that above is for the first ever run after installation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] Directory read returns broken FileEntry objects [cordova-plugin-file]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on issue #653:
URL: https://github.com/apache/cordova-plugin-file/issues/653#issuecomment-4106605362
This is very likely a caveat with the browser platform/implementation of the file plugin.
> Using Cordova Browser for testing on Linux Mint 22.3.
Are you using the browser platform just for testing before moving onto other platforms or are you using the browser platform as your final product target?
If the former, it may be worth attempting the test on Android and/or iOS to see if the issue also reproduces on those platforms. Browser platform only issues tends to stay low on the priority stack.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org