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

Issue when saving multiple files #4

Open
satnam27 opened this issue Dec 3, 2023 · 1 comment
Open

Issue when saving multiple files #4

satnam27 opened this issue Dec 3, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@satnam27
Copy link

satnam27 commented Dec 3, 2023

Hi, I am working on an app. Inside the app user picks a file and it get copied to cache and then manipulation are applied. Before saving its multiple versions to selected directory. Plugin works fine when a single is saved but whenever multiple SaveFileInfo objects are passed to the saveFiles[] array inside the FileSaverParams, it saves all the files that are present in the cache memory. Also it ignored the names as well.

Here is the function that is used to save multiple files. :

 Future<List<String>?> SaveMulti(String path) async{
     List<String>? result;
    result = await PickOrSave().fileSaver(
         params: FileSaverParams(
           saveFiles: [
             SaveFileInfo(
                filePath: path,
                fileName: "file.pdf",
            ),
            SaveFileInfo(
              filePath: path,
              fileName: "file_2.pdf",
            ),
          ],
        )
    );
  return result;
}

For the sake of example, the same path is used for both files. The paths could be different in production for each files.

Here is the log output that is generated:

D/PickOrSavePlugin(15029): onMethodCall - IN , method=pickFiles
D/PickOrSave(15029): pickFile - IN, allowedExtensions=[], mimeTypesFilter=[], localOnly=false, copyFileToCacheDir=true, pickerType=File, enableMultipleSelection=false
D/PickOrSavePlugin(15029): pickFile - OUT
I/System.out(15029): Elapsed time in nanoseconds: 7622200
D/EGL_emulation(15029): eglMakeCurrent: 0xec6610e0: ver 3 0 (tinfo 0xd5734090)
I/System.out(15029): Elapsed time in nanoseconds: 311600
D/PickOrSavePlugin(15029): Picked file: content://com.android.externalstorage.documents/document/primary%3APdfs%2Fhih.pdf
D/PickOrSavePlugin(15029): Launch...
D/PickOrSavePlugin(15029): Copy on background...
D/PickOrSavePlugin(15029): Copying 'content://com.android.externalstorage.documents/document/primary%3APdfs%2Fhih.pdf' to '/data/user/0/com.example.test_j/cache/hih.2272588982937325117.pdf'
D/PickOrSavePlugin(15029): Successfully copied file to '/data/user/0/com.example.test_j/cache/hih.2272588982937325117.pdf, bytes=1739242'
D/EGL_emulation(15029): eglMakeCurrent: 0xec605f40: ver 3 0 (tinfo 0xd2c75730)
D/EGL_emulation(15029): eglMakeCurrent: 0xec605f40: ver 3 0 (tinfo 0xd2c75730)
D/PickOrSavePlugin(15029): ...copied on background, result: /data/user/0/com.example.test_j/cache/hih.2272588982937325117.pdf
D/PickOrSavePlugin(15029): ...launch
I/System.out(15029): filePicking result cleared
I/System.out(15029): Elapsed time in nanoseconds: 184008400
D/EGL_emulation(15029): eglMakeCurrent: 0xec6610e0: ver 3 0 (tinfo 0xd5734090)
D/PickOrSavePlugin(15029): onMethodCall - IN , method=saveFiles
D/PickOrSave(15029): saveFile - IN, saveFiles=[SaveFileInfo(filePath=/data/user/0/com.example.test_j/cache/hih.2272588982937325117.pdf, fileData=null, fileName=file.pdf), SaveFileInfo(filePath=/data/user/0/com.example.test_j/cache/hih.2272588982937325117.pdf, fileData=null, fileName=file_2.pdf)], mimeTypesFilter=[], localOnly=false
D/PickOrSavePlugin(15029): saveFile - OUT
I/System.out(15029): Elapsed time in nanoseconds: 18574800
D/EGL_emulation(15029): eglMakeCurrent: 0xec6610e0: ver 3 0 (tinfo 0xd5734090)
E/eglCodecCommon(15029): goldfish_dma_create_region: could not obtain fd to device! fd 0 errno=11
I/System.out(15029): Elapsed time in nanoseconds: 229000
D/PickOrSavePlugin(15029): Saving file on background...
D/PickOrSavePlugin(15029): hih.1965357157916328852
D/PickOrSavePlugin(15029): Saving file '/data/user/0/com.example.test_j/cache/hih.1965357157916328852.pdf' to '/tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.1965357157916328852 (2).pdf'
D/PickOrSavePlugin(15029): Saved file to '/tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.1965357157916328852 (2).pdf'
D/EGL_emulation(15029): eglMakeCurrent: 0xec605f40: ver 3 0 (tinfo 0xd2c75730)
D/EGL_emulation(15029): eglMakeCurrent: 0xec605f40: ver 3 0 (tinfo 0xd2c75730)
D/EGL_emulation(15029): eglMakeCurrent: 0xec6610e0: ver 3 0 (tinfo 0xd5734090)
D/PickOrSavePlugin(15029): hih.1965357157916328852
D/PickOrSavePlugin(15029): Saving file '/data/user/0/com.example.test_j/cache/hih.1965357157916328852.pdf' to '/tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.1965357157916328852 (3).pdf'
D/PickOrSavePlugin(15029): Saved file to '/tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.1965357157916328852 (3).pdf'
D/PickOrSavePlugin(15029): hih.2272588982937325117
D/PickOrSavePlugin(15029): Saving file '/data/user/0/com.example.test_j/cache/hih.2272588982937325117.pdf' to '/tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.2272588982937325117.pdf'
D/PickOrSavePlugin(15029): Saved file to '/tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.2272588982937325117.pdf'
D/PickOrSavePlugin(15029): hih.2272588982937325117
D/PickOrSavePlugin(15029): Saving file '/data/user/0/com.example.test_j/cache/hih.2272588982937325117.pdf' to '/tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.2272588982937325117 (1).pdf'
D/PickOrSavePlugin(15029): Saved file to '/tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.2272588982937325117 (1).pdf'
D/PickOrSavePlugin(15029): ...saved file on background, result: [/tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.1965357157916328852 (2).pdf, /tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.1965357157916328852 (3).pdf, /tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.2272588982937325117.pdf, /tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.2272588982937325117 (1).pdf]
I/System.out(15029): fileSaving result cleared
I/System.out(15029): Elapsed time in nanoseconds: 302553100

In the above log, it seems saveFiles[] has correct information about the files but

[SaveFileInfo(filePath=/data/user/0/com.example.test_j/cache/hih.2272588982937325117.pdf, fileData=null, fileName=file.pdf), SaveFileInfo(filePath=/data/user/0/com.example.test_j/cache/hih.2272588982937325117.pdf, fileData=null, fileName=file_2.pdf)], 

Instead of saving those two file it saves all the files from cache(that what look like happens):

[/tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.1965357157916328852 (2).pdf, /tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.1965357157916328852 (3).pdf, /tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.2272588982937325117.pdf, /tree/primary:Pdfs/pagecount/Test/document/primary:Pdfs/pagecount/Test/hih.2272588982937325117 (1).pdf]

Any idea why it is happening.

Thanks.

@satnam27 satnam27 changed the title Copying all files that are cached Issue when saving multiple files Dec 3, 2023
@chaudharydeepanshu
Copy link
Owner

Thanks for reporting this issue. I will look into it.

@chaudharydeepanshu chaudharydeepanshu self-assigned this Jan 7, 2024
@chaudharydeepanshu chaudharydeepanshu added the bug Something isn't working label Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants