weixin_40001924 2020-11-30 12:10
浏览 0

File.listDir no longer works for ms-appdata:///local on Windows

I'm submitting a ... (check one with "x") [x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/

Current behavior: I have an Ionic Cordova application, where I also include a windows build. I use the File plugin to write out logging information to a text file.

After I updated to Ionic 4 (and updated all the related plugins), the same File could no longer work on Windows. It still works on iOS and Android, but on Windows, file.listDir always gives {"code":1,"message":"NOT_FOUND_ERR"}

whe called with file.checkDir("ms-appdata:///local", "");

Expected behavior:

Would like this to list the folder entries as it use to, with no error.

Steps to reproduce:

I have put together a sample app to demonstrate this error, which can be clones from https://github.com/pjc2007/ionicfilewindows.git

It needs to run on Windows (eg Window 10 desktop), so need to build via ionic cordova build windows -- --archs="x64".

I then run the built project in Visual Studio 2017, so I can see the console logging output.

The test code is all in home.page.ts.

I have copied most of the relevant source code from listDir function, and added in here so I could add console.logs to try and see where it is failing.

Running the test app, and clicking the test button, which calls checkFile(), I see the following console output...


baseFolder: ms-appdata:///local/
home-home-module-es2015.js (120,17)
exists: true
home-home-module-es2015.js (122,17)
resolveLocalFilesystemUrl: {"isFile":false,"isDirectory":true,"name":"LocalState","fullPath":"/","filesystem":"<filesystem: persistent>","nativeURL":"ms-appdata:///local/"}
home-home-module-es2015.js (158,13)
resolveDirectoryUrl: {"isFile":false,"isDirectory":true,"name":"LocalState","fullPath":"/","filesystem":"<filesystem: persistent>","nativeURL":"ms-appdata:///local/"}
home-home-module-es2015.js (144,13)
-- calling getDirectory with directoryName: , directoryEntry: {"isFile":false,"isDirectory":true,"name":"LocalState","fullPath":"/","filesystem":"<filesystem: persistent>","nativeURL":"ms-appdata:///local/"}, flags: {"create":false,"exclusive":false}
home-home-module-es2015.js (186,17)
getDirectory failed 1: {"code":1,"message":"NOT_FOUND_ERR"}
home-home-module-es2015.js (192,21)
{"code":1,"message":"NOT_FOUND_ERR"}
home-home-module-es2015.js (132,17)
</filesystem:></filesystem:></filesystem:>

So, we can see the call to getDirectory is where it fails...

image

The arguments are directoryName: , directoryEntry: {"isFile":false,"isDirectory":true,"name":"LocalState","fullPath":"/","filesystem":"<FileSystem: persistent>","nativeURL":"ms-appdata:///local/"}

Something worth noting (no idea if related)... Elsewhere, when running on Windows, (eg references to images etc) I have always had to use ./ instead of just /, and I can see the "fullPath":"/" in the logged output of the input DirectoryEntry

Could this be related?

I can try any suggestions

Other information:

I also initially logged a support post here

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):


$ ionic info

Ionic:

   Ionic CLI                     : 5.2.3 (C:\Users\pchapman\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : /angular 4.11.1
   -devkit/build-angular : 0.801.3
   -devkit/schematics    : 8.1.3
   /cli                  : 8.1.3
   /angular-toolkit        : 2.0.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib.0.1)
   Cordova Platforms : android 8.1.0, windows 6.0.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.2, (and 5 other plugins)

Utility:

   cordova-res : 0.7.0-testing.0
   native-run  : 0.2.8

System:

   Android SDK Tools : 26.1.1 (C:\Users\pchapman\AppData\Local\Android\sdk)
   NodeJS            : v10.15.3 (C:\Program Files\nodejs\node.exe)
   npm               : 6.4.1
   OS                : Windows 10

该提问来源于开源项目:ionic-team/ionic-native

  • 写回答

5条回答 默认 最新

  • weixin_40001924 2020-11-30 12:10
    关注

    Hi, don't suppose anyone has had a chance to have a quick look at this?

    评论

报告相同问题?