Skip to content

downloading a file twice seems to fail #25

@thoth-seshat

Description

@thoth-seshat

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions