Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move

Manav Rathi237495d48fe5
diff --git a/web/apps/photos/src/services/upload/uploadManager.ts b/web/apps/photos/src/services/upload/uploadManager.ts
index 96ec37c3c3..c55b377c25 100644
--- a/web/apps/photos/src/services/upload/uploadManager.ts
+++ b/web/apps/photos/src/services/upload/uploadManager.ts
@@ -10,6 +10,7 @@ import { FileType } from "@/media/file-type";
import { potentialFileTypeFromExtension } from "@/media/live-photo";
import { getLocalFiles } from "@/new/photos/services/files";
import { indexNewUpload } from "@/new/photos/services/ml";
+import { getDisableCFUploadProxyFlag } from "@/new/photos/services/settings";
import type { UploadItem } from "@/new/photos/services/upload/types";
import {
RANDOM_PERCENTAGE_PROGRESS_FOR_PUT,
@@ -25,7 +26,6 @@ import {
getLocalPublicFiles,
getPublicCollectionUID,
} from "services/publicCollectionService";
-import { getDisableCFUploadProxyFlag } from "services/userService";
import watcher from "services/watch";
import { decryptFile, getUserOwnedFiles } from "utils/file";
import {
diff --git a/web/apps/photos/src/services/userService.ts b/web/apps/photos/src/services/userService.ts
index 50c8e19dce..f6fb67ea3a 100644
--- a/web/apps/photos/src/services/userService.ts
+++ b/web/apps/photos/src/services/userService.ts
@@ -1,16 +1,12 @@
import { putAttributes } from "@/accounts/api/user";
import log from "@/base/log";
-import { apiURL, customAPIOrigin, familyAppOrigin } from "@/base/origins";
+import { apiURL, familyAppOrigin } from "@/base/origins";
import { ApiError } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
import { getToken } from "@ente/shared/storage/localStorage/helpers";
import { HttpStatusCode } from "axios";
-import {
- DeleteChallengeResponse,
- GetFeatureFlagResponse,
- UserDetails,
-} from "types/user";
+import { DeleteChallengeResponse, UserDetails } from "types/user";
import { getLocalFamilyData, isPartOfFamily } from "utils/user/family";
const HAS_SET_KEYS = "hasSetKeys";
@@ -172,36 +168,3 @@ export const deleteAccount = async (
throw e;
}
};
-
-/**
- * Return true to disable the upload of files via Cloudflare Workers.
- *
- * These workers were introduced as a way of make file uploads faster:
- * https://ente.io/blog/tech/making-uploads-faster/
- *
- * By default, that's the route we take. However, during development or when
- * self-hosting it can be convenient to turn this flag on to directly upload to
- * the S3-compatible URLs returned by the ente API.
- *
- * Note the double negative (Enhancement: maybe remove the double negative,
- * rename this to say getUseDirectUpload).
- */
-export async function getDisableCFUploadProxyFlag(): Promise<boolean> {
- // If a custom origin is set, that means we're not running a production
- // deployment (maybe we're running locally, or being self-hosted).
- //
- // In such cases, disable the Cloudflare upload proxy (which won't work for
- // self-hosters), and instead just directly use the upload URLs that museum
- // gives us.
- if (await customAPIOrigin()) return true;
-
- try {
- const featureFlags = (
- await fetch("https://static.ente.io/feature_flags.json")
- ).json() as GetFeatureFlagResponse;
- return featureFlags.disableCFUploadProxy;
- } catch (e) {
- log.error("failed to get feature flags", e);
- return false;
- }
-}
diff --git a/web/apps/photos/src/types/user/index.ts b/web/apps/photos/src/types/user/index.ts
index ca407980f8..bbdbd5d021 100644
--- a/web/apps/photos/src/types/user/index.ts
+++ b/web/apps/photos/src/types/user/index.ts
@@ -83,7 +83,3 @@ export interface CreateSRPSessionResponse {
sessionID: string;
srpB: string;
}
-
-export interface GetFeatureFlagResponse {
- disableCFUploadProxy?: boolean;
-}
diff --git a/web/packages/new/photos/services/settings.ts b/web/packages/new/photos/services/settings.ts
index 4f4272468a..5566945ed0 100644
--- a/web/packages/new/photos/services/settings.ts
+++ b/web/packages/new/photos/services/settings.ts
@@ -6,6 +6,7 @@
import { localUser } from "@/base/local-user";
import log from "@/base/log";
+import { customAPIOrigin } from "@/base/origins";
import { nullToUndefined } from "@/utils/transform";
import { z } from "zod";
import { fetchFeatureFlags, updateRemoteFlag } from "./remote-store";
@@ -193,3 +194,40 @@ export const updateMapEnabled = async (isEnabled: boolean) => {
await updateRemoteFlag("mapEnabled", isEnabled);
return syncSettings();
};
+
+/**
+ * Return true to disable the upload of files via Cloudflare Workers.
+ *
+ * These workers were introduced as a way of make file uploads faster:
+ * https://ente.io/blog/tech/making-uploads-faster/
+ *
+ * By default, that's the route we take. However, during development or when
+ * self-hosting it can be convenient to turn this flag on to directly upload to
+ * the S3-compatible URLs returned by the ente API.
+ *
+ * Note the double negative (Enhancement: maybe remove the double negative,
+ * rename this to say getUseDirectUpload).
+ */
+export async function getDisableCFUploadProxyFlag(): Promise<boolean> {
+ // If a custom origin is set, that means we're not running a production
+ // deployment (maybe we're running locally, or being self-hosted).
+ //
+ // In such cases, disable the Cloudflare upload proxy (which won't work for
+ // self-hosters), and instead just directly use the upload URLs that museum
+ // gives us.
+ if (await customAPIOrigin()) return true;
+
+ try {
+ const featureFlags = (
+ await fetch("https://static.ente.io/feature_flags.json")
+ ).json() as GetFeatureFlagResponse;
+ return featureFlags.disableCFUploadProxy ?? false;
+ } catch (e) {
+ log.error("failed to get feature flags", e);
+ return false;
+ }
+}
+
+export interface GetFeatureFlagResponse {
+ disableCFUploadProxy?: boolean;
+}