summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandomChars <random@chars.jp>2021-11-23 15:10:35 +0900
committerRandomChars <random@chars.jp>2021-11-23 15:10:35 +0900
commit3e66377c469674b90066b6e64e5a431cd46ac9a5 (patch)
tree52fdfc72e78db7e9dcc1739fb42425a2142ec10e
parent685fa86ad3d72bb4b9024d0288a9b4210e3224de (diff)
check error properly in mustGetUser, fix paths
-rw-r--r--api/f.go2
-rw-r--r--backend/filesystem/image.go6
-rw-r--r--backend/filesystem/secret.go2
-rw-r--r--backend/filesystem/user.go2
4 files changed, 6 insertions, 6 deletions
diff --git a/api/f.go b/api/f.go
index 987053e..3745dc5 100644
--- a/api/f.go
+++ b/api/f.go
@@ -43,7 +43,7 @@ func (s *Server) getUser(context *gin.Context) (*store.User, error) {
}
func (s *Server) mustGetUser(context *gin.Context) *store.User {
- if user, err := s.getUser(context); err == store.ErrNoEntry {
+ if user, err := s.getUser(context); err == store.ErrNoEntry || err == store.ErrInvalidInput {
context.JSON(http.StatusUnauthorized, ErrUnauthorized)
return nil
} else if doError(context, err) {
diff --git a/backend/filesystem/image.go b/backend/filesystem/image.go
index 3f2b2e4..f1aa541 100644
--- a/backend/filesystem/image.go
+++ b/backend/filesystem/image.go
@@ -267,10 +267,10 @@ func (s *Store) ImageAdd(data []byte, flake string) (*store.Image, error) {
return nil, err
}
- if err := s.link("../images/"+s.ImageHashSplit(info.Hash), s.ImageSnowflakePath(info.Snowflake)); err != nil {
+ if err := s.link("../hashes/"+s.ImageHashSplit(info.Hash), s.ImageSnowflakePath(info.Snowflake)); err != nil {
return nil, err
}
- if err := s.link("../../../images/"+s.ImageHashSplit(info.Hash), s.UserImagesPath(flake)+"/"+info.Snowflake); err != nil {
+ if err := s.link("../../../images/hashes/"+s.ImageHashSplit(info.Hash), s.UserImagesPath(flake)+"/"+info.Snowflake); err != nil {
return nil, err
}
@@ -504,7 +504,7 @@ func (s *Store) ImageTagAdd(flake, tag string) error {
s.getLock(flake).Lock()
defer s.getLock(flake).Unlock()
- if err := s.link("../../snowflakes/"+flake, s.TagPath(tag)+"/"+flake); err != nil {
+ if err := s.link("../../images/snowflakes/"+flake, s.TagPath(tag)+"/"+flake); err != nil {
return err
}
if err := s.link("../../../../tags/"+tag, s.ImageSnowflakePath(flake)+"/tags/"+tag); err != nil {
diff --git a/backend/filesystem/secret.go b/backend/filesystem/secret.go
index 1fc3600..a98c5eb 100644
--- a/backend/filesystem/secret.go
+++ b/backend/filesystem/secret.go
@@ -35,7 +35,7 @@ func (s *Store) secretAssociate(secret, flake string) error {
if s.file(s.SecretPath(secret)) {
return store.ErrAlreadyExists
}
- return s.link("../users/"+flake, s.SecretPath(secret))
+ return s.link("../snowflakes/"+flake, s.SecretPath(secret))
}
// secretDisassociate disassociates a secret.
diff --git a/backend/filesystem/user.go b/backend/filesystem/user.go
index 5d3958c..9d21c6a 100644
--- a/backend/filesystem/user.go
+++ b/backend/filesystem/user.go
@@ -228,7 +228,7 @@ func (s *Store) UserUsername(username string) (*store.User, error) {
// userUsernameAssociate associates user snowflake with specific username.
func (s *Store) userUsernameAssociate(flake, username string) error {
- return s.link("../users/"+flake, s.UsernamePath(username))
+ return s.link("../snowflakes/"+flake, s.UsernamePath(username))
}
// userUsernameDisassociate disassociates specific username.