Skip to content
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

Error: File index.html could not be deleted because it could not be found] ( Facing issue only on Android device ) #110

Closed
Sharvin26 opened this issue Jul 1, 2020 · 6 comments

Comments

@Sharvin26
Copy link

Sharvin26 commented Jul 1, 2020

Issue Description

I am getting the following issue when displaying the PDF file ( Only on Android device not on the IOS device ):

[Unhandled promise rejection: Error: File 'file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540user26%252FAppName/index.html' could not be deleted because it could not be found]
- node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:99:50 in fn
- node_modules/@unimodules/react-native-adapter/build/NativeModulesProxy.js:15:46 in moduleName.methodInfo.name
- node_modules/expo-file-system/build/FileSystem.js:56:48 in deleteAsync
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:274:30 in invoke
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:135:28 in invoke
- node_modules/regenerator-runtime/runtime.js:170:17 in PromiseImpl$argument_0
- node_modules/promise/setimmediate/core.js:45:7 in tryCallTwo
- node_modules/promise/setimmediate/core.js:200:23 in doResolve
- node_modules/promise/setimmediate/core.js:66:12 in Promise
- node_modules/regenerator-runtime/runtime.js:169:31 in PromiseImpl$argument_0
- node_modules/regenerator-runtime/runtime.js:192:38 in enqueue
- node_modules/regenerator-runtime/runtime.js:219:8 in exports.async
- node_modules/expo-file-system/build/FileSystem.js:52:7 in deleteAsync
- node_modules/rn-pdf-reader-js/lib/index.js:64:7 in removeFilesAsync
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:274:30 in invoke
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:135:28 in invoke
- node_modules/regenerator-runtime/runtime.js:145:19 in PromiseImpl.resolve.then$argument_0
- node_modules/promise/setimmediate/core.js:37:14 in tryCallOne
- node_modules/promise/setimmediate/core.js:123:25 in setImmediate$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:146:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:194:17 in _callImmediatesPass
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:458:30 in callImmediates
* [native code]:null in callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:407:6 in __callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:143:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:142:17 in __guard$argument_0
* [native code]:null in flushedQueue
* [native code]:null in invokeCallbackAndReturnFlushedQueue

Steps to Reproduce / Code Snippets

  1. I am using Document Picker from expo SDK, So that user picks the PDF that he wants.
const doc = await DocumentPicker.getDocumentAsync({
    type: "application/pdf",
});
  1. After that I am using FileSystem from expo SDK to move the file from temporary to permanent directory.
const newPath = FileSystem.documentDirectory + fileName;
await FileSystem.moveAsync({
      from: uri,
      to: newPath,
});
  1. I am saving this data in my local database and after that displaying it to the user using the following code:
<PDFReader
     style={{
        width: "100%",
        height: "100%",
        justifyContent: "flex-end",
        borderRadius: 10,
        overflow: "hidden",
    }}
    source={{
         uri: props.pdfUri,
    }}
    webviewProps={{
         scrollEnabled: false,
   }}
/>

Expected Results

On IOS device it is working properly but on android it is not working properly. Expected result is that it should work properly on both the devices.

Additional Information

  • Nodejs version: v12.16.1
  • React version: 16.9.0
  • React Native version: 0.61
  • Expo version: 37.0.1
  • rn-pdf-reader-js version: 3.1.0
  • Platform(s) (iOS, Android, or both?): Android
  • TypeScript version: Not Using
@xcarpentier
Copy link
Owner

Hi,
Apparently the package tries to delete index.html that was already deleted or not present for some reason.
It may fix it to add a check existing file before delete.
I change deleteAsync option like this:

https://github.com/xcarpentier/rn-pdf-reader-js/blob/master/src/index.tsx#L152-L162

doc: https://docs.expo.io/versions/latest/sdk/filesystem/#arguments-3

@Sharvin26
Copy link
Author

Hello, basically I should add a check to see if file exists or not before moveAsync API. Right?

@xcarpentier
Copy link
Owner

Should be fixed into v4.0.0. Can you check?

@Sharvin26
Copy link
Author

Sharvin26 commented Jul 10, 2020

Above error is fixed but I am seeing a weird behavior when displaying the PDF side by side on same screen. I am using Flatlist to show the PDF Documents side by side.

I am seeing same PDF document side by side when both PDF that I have uploaded are different. On IOS I am able to see different PDF side by side but this issue only occurs on Android. Please see the screenshot below to see the issue and behavioral difference between IOS and android.

Android:
Screenshot_20200710-121517

IOS:
Simulator Screen Shot - iPhone 11 - 2020-07-10 at 12 19 00

Following are the path for the both the files:

  • File 1:
    file:///data/user/0/host.exp.exponent/files/ExperienceData/%2540userName%252FAppName/909988fb-a4e4-457c-8c62-6cbc540134b6.pdf

  • File 2:
    file:///data/user/0/host.exp.exponent/files/ExperienceData/%2540userName26%252FAppName/86e383af-4779-46c4-913e-a947db78673a.pdf

Also is there any way that I can suppress these log lines that are printed by default by this library?. ( i.e. Hide them )

URL_TO_BASE64
URL_TO_BASE64

@xcarpentier
Copy link
Owner

Please open an other issue :)

@Sharvin26
Copy link
Author

Okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants