diff options
Diffstat (limited to 'src/server/ApiManagers')
| -rw-r--r-- | src/server/ApiManagers/DownloadManager.ts | 6 | ||||
| -rw-r--r-- | src/server/ApiManagers/GooglePhotosManager.ts | 9 | ||||
| -rw-r--r-- | src/server/ApiManagers/UploadManager.ts | 3 | ||||
| -rw-r--r-- | src/server/ApiManagers/UtilManager.ts | 7 | 
4 files changed, 19 insertions, 6 deletions
| diff --git a/src/server/ApiManagers/DownloadManager.ts b/src/server/ApiManagers/DownloadManager.ts index 1bb84f374..fad5e6789 100644 --- a/src/server/ApiManagers/DownloadManager.ts +++ b/src/server/ApiManagers/DownloadManager.ts @@ -254,11 +254,13 @@ async function writeHierarchyRecursive(file: Archiver.Archiver, hierarchy: Hiera                  // and dropped in the browser and thus hosted remotely) so we upload it                  // to our server and point the zip file to it, so it can bundle up the bytes                  const information = await DashUploadUtils.UploadImage(result); -                path = information.serverAccessPaths[SizeSuffix.Original]; +                path = information instanceof Error ? "" : information.serverAccessPaths[SizeSuffix.Original];              }              // write the file specified by the path to the directory in the              // zip file given by the prefix. -            file.file(path, { name: documentTitle, prefix }); +            if (path) { +                file.file(path, { name: documentTitle, prefix }); +            }          } else {              // we've hit a collection, so we have to recurse              await writeHierarchyRecursive(file, result, `${prefix}/${documentTitle}`); diff --git a/src/server/ApiManagers/GooglePhotosManager.ts b/src/server/ApiManagers/GooglePhotosManager.ts index 107542ce2..1727cc5a6 100644 --- a/src/server/ApiManagers/GooglePhotosManager.ts +++ b/src/server/ApiManagers/GooglePhotosManager.ts @@ -88,8 +88,13 @@ export default class GooglePhotosManager extends ApiManager {                  if (contents) {                      const completed: Opt<DashUploadUtils.ImageUploadInformation>[] = [];                      for (const item of contents.mediaItems) { -                        const { contentSize, ...attributes } = await DashUploadUtils.InspectImage(item.baseUrl); -                        const found: Opt<DashUploadUtils.ImageUploadInformation> = await Database.Auxiliary.QueryUploadHistory(contentSize!); +                        const results = await DashUploadUtils.InspectImage(item.baseUrl); +                        if (results instanceof Error) { +                            failed++; +                            continue; +                        } +                        const { contentSize, ...attributes } = results; +                        const found: Opt<DashUploadUtils.ImageUploadInformation> = await Database.Auxiliary.QueryUploadHistory(contentSize);                          if (!found) {                              const upload = await DashUploadUtils.UploadInspectedImage({ contentSize, ...attributes }, item.filename, prefix).catch(error => _error(res, downloadError, error));                              if (upload) { diff --git a/src/server/ApiManagers/UploadManager.ts b/src/server/ApiManagers/UploadManager.ts index a92b613b7..4d09528f4 100644 --- a/src/server/ApiManagers/UploadManager.ts +++ b/src/server/ApiManagers/UploadManager.ts @@ -65,7 +65,8 @@ export default class UploadManager extends ApiManager {              secureHandler: async ({ req, res }) => {                  const { sources } = req.body;                  if (Array.isArray(sources)) { -                    return res.send(await Promise.all(sources.map(url => DashUploadUtils.UploadImage(url)))); +                    const results = await Promise.all(sources.map(source => DashUploadUtils.UploadImage(source))); +                    return res.send(results);                  }                  res.send();              } diff --git a/src/server/ApiManagers/UtilManager.ts b/src/server/ApiManagers/UtilManager.ts index a0d0d0f4b..d7b085a30 100644 --- a/src/server/ApiManagers/UtilManager.ts +++ b/src/server/ApiManagers/UtilManager.ts @@ -47,7 +47,12 @@ export default class UtilManager extends ApiManager {                  const onResolved = (stdout: string) => { console.log(stdout); res.redirect("/"); };                  const onRejected = (err: any) => { console.error(err.message); res.send(err); }; -                const tryPython3 = () => command_line('python3 scraper.py', cwd).then(onResolved, onRejected); +                const tryPython3 = (reason: any) => { +                    console.log("Initial scraper failed for the following reason:"); +                    console.log(red(reason.Error)); +                    console.log("Falling back to python3..."); +                    command_line('python3 scraper.py', cwd).then(onResolved, onRejected); +                };                  return command_line('python scraper.py', cwd).then(onResolved, tryPython3);              }, | 
