Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

add missing token check

Abhinavfc15f007adb5
diff --git a/apps/photos/src/services/downloadManagerClients/photos.ts b/apps/photos/src/services/downloadManagerClients/photos.ts
index da77b45f30..783bef1920 100644
--- a/apps/photos/src/services/downloadManagerClients/photos.ts
+++ b/apps/photos/src/services/downloadManagerClients/photos.ts
@@ -17,7 +17,7 @@ export class PhotosDownloadClient implements DownloadClient {
async downloadThumbnail(file: EnteFile): Promise<Uint8Array> {
if (!this.token) {
- return;
+ throw Error(CustomError.TOKEN_MISSING);
}
const resp = await retryAsyncFunction(() =>
HTTPService.get(
@@ -37,6 +37,9 @@ export class PhotosDownloadClient implements DownloadClient {
file: EnteFile,
onDownloadProgress: (event: { loaded: number; total: number }) => void
): Promise<Uint8Array> {
+ if (!this.token) {
+ throw Error(CustomError.TOKEN_MISSING);
+ }
const resp = await retryAsyncFunction(() =>
HTTPService.get(
getFileURL(file.id),
@@ -56,6 +59,9 @@ export class PhotosDownloadClient implements DownloadClient {
}
async downloadFileStream(file: EnteFile): Promise<Response> {
+ if (!this.token) {
+ throw Error(CustomError.TOKEN_MISSING);
+ }
return retryAsyncFunction(() =>
fetch(getFileURL(file.id), {
headers: {
diff --git a/apps/photos/src/services/downloadManagerClients/publicAlbums.ts b/apps/photos/src/services/downloadManagerClients/publicAlbums.ts
index 7a93e0e2af..f4970b38c9 100644
--- a/apps/photos/src/services/downloadManagerClients/publicAlbums.ts
+++ b/apps/photos/src/services/downloadManagerClients/publicAlbums.ts
@@ -25,6 +25,9 @@ export class PublicAlbumsDownloadClient implements DownloadClient {
}
downloadThumbnail = async (file: EnteFile) => {
+ if (!this.token) {
+ throw Error(CustomError.TOKEN_MISSING);
+ }
const resp = await HTTPService.get(
getPublicCollectionThumbnailURL(file.id),
null,
@@ -47,6 +50,9 @@ export class PublicAlbumsDownloadClient implements DownloadClient {
file: EnteFile,
onDownloadProgress: (event: { loaded: number; total: number }) => void
) => {
+ if (!this.token) {
+ throw Error(CustomError.TOKEN_MISSING);
+ }
const resp = await retryAsyncFunction(() =>
HTTPService.get(
getPublicCollectionFileURL(file.id),
@@ -67,6 +73,9 @@ export class PublicAlbumsDownloadClient implements DownloadClient {
};
async downloadFileStream(file: EnteFile): Promise<Response> {
+ if (!this.token) {
+ throw Error(CustomError.TOKEN_MISSING);
+ }
return retryAsyncFunction(() =>
fetch(getPublicCollectionFileURL(file.id), {
headers: {