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

downloading a file twice seems to fail #25

Open
thoth-seshat opened this issue Jan 3, 2024 · 1 comment
Open

downloading a file twice seems to fail #25

thoth-seshat opened this issue Jan 3, 2024 · 1 comment

Comments

@thoth-seshat
Copy link

I have a setup like this:

    let file;

      
      await new Promise<void>((resolve, reject) => {
        CloudStore.download(filePath, {
          onProgress: async (progress) => {
            console.log("progress", progress);
            if (progress.progress === 100) {
              file = await CloudStore.readFile(filePath);
              resolve();
            }
          },
        });
      });

The first time I run this, it seems to work fine however, the second time I run this, it will fail. I'm not sure why.

My file path is created like this:

  function mkICloudFilePath(fileName?: string) {
   if (!defaultIPath) return new Error("No default iCloud folder found");

   const iCloudUrl = CloudStore.getICloudURL().then((url) => {
     console.log("iCloudUrl", url);
   });

   console.log("defaultIPath", defaultIPath);

   return CloudStore.PathUtils.join(defaultIPath, `Documents/${fileName}`);
 }

It seems like the file is downloaded but won't persist in the iCloud folder for some reason and then the second time I try to access it it says it doesn't exit. With a WARN Possible Unhandled Promise Rejection (id: 1):

I'm also seeing the progress indicator from the onICloudDocumentsUpdateGathering events showing progress 0 before it dies.

If the file is already downloaded does it die again? I'm confused on what download does vs startDownloadingUbiquitousItem and I'm not sure which should be used. I need to ensure the file exists so I can read it in and process it.

@XHMM
Copy link
Owner

XHMM commented Jan 4, 2024

Re-call download should be fine. Can you log the rejection to see what the error message was?

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