Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

feat: return not found error instead internal error for local file not exist (#3543)

Ryo2c819ace4e60
diff --git a/.gitignore b/.gitignore
index e19fa0630..c12f0f319 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,4 +22,7 @@ bin/air
dev-dist
-dist
\ No newline at end of file
+dist
+
+# VSCode settings
+/.vscode
diff --git a/server/router/api/v1/resource_service.go b/server/router/api/v1/resource_service.go
index a49199232..3004cf243 100644
--- a/server/router/api/v1/resource_service.go
+++ b/server/router/api/v1/resource_service.go
@@ -198,6 +198,9 @@ func (s *APIV1Service) GetResourceBinary(ctx context.Context, request *v1pb.GetR
file, err := os.Open(resourcePath)
if err != nil {
+ if os.IsNotExist(err) {
+ return nil, status.Errorf(codes.NotFound, "file not found for resource: %s", request.Name)
+ }
return nil, status.Errorf(codes.Internal, "failed to open the file: %v", err)
}
defer file.Close()