Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove unused file endpoints

Neeraj Guptadd5d9051eab0
diff --git a/server/cmd/museum/main.go b/server/cmd/museum/main.go
index c2f91fcd30..c3fcd5e527 100644
--- a/server/cmd/museum/main.go
+++ b/server/cmd/museum/main.go
@@ -620,7 +620,6 @@ func main() {
storageAPI.POST("/files/size", fileHandler.GetSize)
storageAPI.POST("/files/info", fileHandler.GetInfo)
storageAPI.GET("/files/duplicates", fileHandler.GetDuplicates)
- storageAPI.GET("/files/large-thumbnails", fileHandler.GetLargeThumbnailFiles)
storageAPI.PUT("/files/thumbnail", fileHandler.UpdateThumbnail)
storageAPI.PUT("/files/magic-metadata", fileHandler.UpdateMagicMetadata)
storageAPI.PUT("/files/public-magic-metadata", fileHandler.UpdatePublicMagicMetadata)
@@ -775,9 +774,7 @@ func main() {
publicCollectionAPI.GET("/files/data/preview", publicCollectionHandler.GetPreviewURL)
publicCollectionAPI.GET("/diff", publicCollectionHandler.GetDiff)
publicCollectionAPI.GET("/info", publicCollectionHandler.GetCollection)
- publicCollectionAPI.GET("/upload-urls", publicCollectionHandler.GetUploadUrls)
publicCollectionAPI.POST("/upload-url", publicCollectionHandler.GetUploadURLV2)
- publicCollectionAPI.GET("/multipart-upload-urls", publicCollectionHandler.GetMultipartUploadURLs)
publicCollectionAPI.POST("/multipart-upload-url", publicCollectionHandler.GetMultipartUploadURLV2)
publicCollectionAPI.POST("/file", publicCollectionHandler.CreateFile)
publicCollectionAPI.POST("/verify-password", publicCollectionHandler.VerifyPassword)
diff --git a/server/pkg/api/file.go b/server/pkg/api/file.go
index 7fa580a0db..4c7bd1f7f5 100644
--- a/server/pkg/api/file.go
+++ b/server/pkg/api/file.go
@@ -354,20 +354,6 @@ func (h *FileHandler) GetDuplicates(c *gin.Context) {
})
}
-// GetLargeThumbnail returns the list of files whose thumbnail size is larger than threshold size
-func (h *FileHandler) GetLargeThumbnailFiles(c *gin.Context) {
- userID := auth.GetUserID(c.Request.Header)
- threshold, _ := strconv.ParseInt(c.Query("threshold"), 10, 64)
- largeThumbnailFiles, err := h.Controller.GetLargeThumbnailFiles(userID, threshold)
- if err != nil {
- handler.Error(c, stacktrace.Propagate(err, ""))
- return
- }
- c.JSON(http.StatusOK, gin.H{
- "largeThumbnailFiles": largeThumbnailFiles,
- })
-}
-
// UpdateMagicMetadata updates magic metadata for a list of files.
func (h *FileHandler) UpdateMagicMetadata(c *gin.Context) {
var request ente.UpdateMultipleMagicMetadataRequest
diff --git a/server/pkg/api/public_collection.go b/server/pkg/api/public_collection.go
index 951349ebdc..e28abc6d69 100644
--- a/server/pkg/api/public_collection.go
+++ b/server/pkg/api/public_collection.go
@@ -122,27 +122,6 @@ func (h *PublicCollectionHandler) GetCollection(c *gin.Context) {
c.JSON(http.StatusOK, response)
}
-// GetUploadUrls returns upload Urls where files can be uploaded
-func (h *PublicCollectionHandler) GetUploadUrls(c *gin.Context) {
- enteApp := auth.GetApp(c)
-
- collection, err := h.Controller.GetPublicCollection(c, true)
- if err != nil {
- handler.Error(c, stacktrace.Propagate(err, ""))
- return
- }
- userID := collection.Owner.ID
- count, _ := strconv.Atoi(c.Query("count"))
- urls, err := h.FileCtrl.GetUploadURLs(c, userID, count, enteApp, false)
- if err != nil {
- handler.Error(c, stacktrace.Propagate(err, ""))
- return
- }
- c.JSON(http.StatusOK, gin.H{
- "urls": urls,
- })
-}
-
// GetUploadURLV2 returns a single upload URL that enforces checksum + content-length headers
func (h *PublicCollectionHandler) GetUploadURLV2(c *gin.Context) {
enteApp := auth.GetApp(c)
@@ -164,27 +143,6 @@ func (h *PublicCollectionHandler) GetUploadURLV2(c *gin.Context) {
c.JSON(http.StatusOK, url)
}
-// GetMultipartUploadURLs returns upload Urls where files can be uploaded
-func (h *PublicCollectionHandler) GetMultipartUploadURLs(c *gin.Context) {
- enteApp := auth.GetApp(c)
-
- collection, err := h.Controller.GetPublicCollection(c, true)
- if err != nil {
- handler.Error(c, stacktrace.Propagate(err, ""))
- return
- }
- userID := collection.Owner.ID
- count, _ := strconv.Atoi(c.Query("count"))
- urls, err := h.FileCtrl.GetMultipartUploadURLs(c, userID, count, enteApp)
- if err != nil {
- handler.Error(c, stacktrace.Propagate(err, ""))
- return
- }
- c.JSON(http.StatusOK, gin.H{
- "urls": urls,
- })
-}
-
// GetMultipartUploadURLV2 returns multipart upload URLs for a single object with enforced metadata
func (h *PublicCollectionHandler) GetMultipartUploadURLV2(c *gin.Context) {
enteApp := auth.GetApp(c)
diff --git a/server/pkg/controller/file.go b/server/pkg/controller/file.go
index f2f9b821a1..00f9c9387e 100644
--- a/server/pkg/controller/file.go
+++ b/server/pkg/controller/file.go
@@ -694,15 +694,6 @@ func (c *FileController) GetDuplicates(userID int64) ([]ente.DuplicateFiles, err
return dupes, nil
}
-// GetLargeThumbnailFiles returns the list of files whose thumbnail size is larger than threshold size
-func (c *FileController) GetLargeThumbnailFiles(userID int64, threshold int64) ([]int64, error) {
- largeThumbnailFiles, err := c.FileRepo.GetLargeThumbnailFiles(userID, threshold)
- if err != nil {
- return nil, stacktrace.Propagate(err, "")
- }
- return largeThumbnailFiles, nil
-}
-
// UpdateMagicMetadata updates the magic metadata for list of files
func (c *FileController) UpdateMagicMetadata(ctx *gin.Context, req ente.UpdateMultipleMagicMetadataRequest, isPublicMetadata bool) error {
err := c.validateUpdateMetadataRequest(ctx, req, isPublicMetadata)
diff --git a/server/pkg/middleware/collection_link_test.go b/server/pkg/middleware/collection_link_test.go
index 0322198891..496bc252f9 100644
--- a/server/pkg/middleware/collection_link_test.go
+++ b/server/pkg/middleware/collection_link_test.go
@@ -11,6 +11,6 @@ func TestShouldCheckCollectionLinkDeviceLimit(t *testing.T) {
require.True(t, shouldCheckCollectionLinkDeviceLimit("/public-collection/diff"))
require.False(t, shouldCheckCollectionLinkDeviceLimit("/public-collection/files/download/1"))
- require.False(t, shouldCheckCollectionLinkDeviceLimit("/public-collection/upload-urls"))
+ require.False(t, shouldCheckCollectionLinkDeviceLimit("/public-collection/upload-url"))
require.False(t, shouldCheckCollectionLinkDeviceLimit("/public-collection/verify-password"))
}
diff --git a/server/pkg/middleware/rate_limit.go b/server/pkg/middleware/rate_limit.go
index bd9d3ad9b2..815acf9aaf 100644
--- a/server/pkg/middleware/rate_limit.go
+++ b/server/pkg/middleware/rate_limit.go
@@ -185,9 +185,7 @@ func (r *RateLimitMiddleware) getRateLimitKey(c *gin.Context, reqPath string) st
}
func isPublicCollectionUploadURLPath(reqPath string) bool {
- return reqPath == "/public-collection/upload-urls" ||
- reqPath == "/public-collection/upload-url" ||
- reqPath == "/public-collection/multipart-upload-urls" ||
+ return reqPath == "/public-collection/upload-url" ||
reqPath == "/public-collection/multipart-upload-url"
}
diff --git a/server/pkg/repo/file.go b/server/pkg/repo/file.go
index 176ac1ae52..8fe86d95c8 100644
--- a/server/pkg/repo/file.go
+++ b/server/pkg/repo/file.go
@@ -783,26 +783,6 @@ func (repo *FileRepository) GetDuplicateFiles(userID int64) ([]ente.DuplicateFil
return result, nil
}
-func (repo *FileRepository) GetLargeThumbnailFiles(userID int64, threshold int64) ([]int64, error) {
- rows, err := repo.DB.Query(`
- SELECT file_id FROM object_keys WHERE o_type = 'thumbnail' AND is_deleted = false AND size >= $2 AND file_id = ANY(SELECT file_id FROM files WHERE owner_id = $1)`,
- userID, threshold)
- if err != nil {
- return nil, stacktrace.Propagate(err, "")
- }
- defer rows.Close()
- result := make([]int64, 0)
- for rows.Next() {
- var fileID int64
- err := rows.Scan(&fileID)
- if err != nil {
- return result, stacktrace.Propagate(err, "")
- }
- result = append(result, fileID)
- }
- return result, nil
-}
-
func (repo *FileRepository) GetTotalFileCount() (int64, error) {
// 9,522,438 is the magic number that accommodates the bumping up of fileIDs
// Doing this magic instead of count(*) since it's faster
diff --git a/web/packages/gallery/services/upload/remote.ts b/web/packages/gallery/services/upload/remote.ts
index a88767b69a..204fad7cae 100644
--- a/web/packages/gallery/services/upload/remote.ts
+++ b/web/packages/gallery/services/upload/remote.ts
@@ -152,25 +152,6 @@ export const fetchPublicAlbumsMultipartUploadURLsWithMetadata = async (
return MultipartUploadURLs.parse(await res.json());
};
-/**
- * Sibling of {@link fetchUploadURLs} for public albums.
- */
-export const fetchPublicAlbumsUploadURLs = async (
- countHint: number,
- credentials: PublicAlbumsCredentials,
-) => {
- const count = Math.min(50, countHint * 2);
- const res = await fetch(
- await apiURL("/public-collection/upload-urls", {
- count,
- ts: Date.now(),
- }),
- { headers: authenticatedPublicAlbumsRequestHeaders(credentials) },
- );
- ensureOk(res);
- return ObjectUploadURLResponse.parse(await res.json()).urls;
-};
-
/**
* A list of URLs to use for multipart uploads.
*
@@ -223,25 +204,6 @@ export const fetchMultipartUploadURLs = async (uploadPartCount: number) => {
return MultipartUploadURLsResponse.parse(await res.json()).urls;
};
-/**
- * Sibling of {@link fetchMultipartUploadURLs} for public albums.
- */
-export const fetchPublicAlbumsMultipartUploadURLs = async (
- uploadPartCount: number,
- credentials: PublicAlbumsCredentials,
-) => {
- const count = uploadPartCount;
- const res = await fetch(
- await apiURL("/public-collection/multipart-upload-urls", {
- count,
- ts: Date.now(),
- }),
- { headers: authenticatedPublicAlbumsRequestHeaders(credentials) },
- );
- ensureOk(res);
- return MultipartUploadURLsResponse.parse(await res.json()).urls;
-};
-
/**
* Upload a file using a pre-signed URL.
*
@@ -493,7 +455,8 @@ const createMultipartUploadRequestBody = (
* call will be different (because of the different authentication
* mechanisms) when we're running in the context of the photos app
* ({@link fetchMultipartUploadURLs}) and when we're running in the context
- * of the public albums app ({@link fetchPublicAlbumsMultipartUploadURLs}).
+ * of the public albums app
+ * ({@link fetchPublicAlbumsMultipartUploadURLsWithMetadata}).
*
* 2. Break the file to be uploaded into parts, and upload each part using a PUT
* request to one of the pre-signed URLs we got in step 1. There are two