Skip to content

Commit

Permalink
Merge pull request #398 from subutai-io/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
crioto authored May 21, 2018
2 parents db4eee7 + 7e39510 commit 41d3004
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 28 deletions.
29 changes: 2 additions & 27 deletions apt/apt.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,33 +132,8 @@ func Upload(w http.ResponseWriter, r *http.Request) {

func Download(w http.ResponseWriter, r *http.Request) {
file := r.URL.Query().Get("hash")
tag := r.URL.Query().Get("tag")
if len(file) == 0 && len(tag) == 0 {
w.Write([]byte("Both hash and tag is empty"))
return
}
if len(file) != 0 {
if len(tag) != 0 {
listbyTag := db.SearchFileByTag(tag, "apt")
for _, l := range listbyTag {
if db.IsPublic(l) {
apt := db.NameByHash(l)
if apt == file {
file = apt
}
}
}
}
} else { //both name and hash is provided
if len(tag) != 0 {
listbyTag := db.SearchFileByTag(tag, "apt")
for _, l := range listbyTag {
if db.IsPublic(l) {
apt := db.NameByHash(l)
file = apt
}
}
}
if len(file) == 0 {
file = strings.TrimPrefix(r.RequestURI, "/kurjun/rest/apt/")
}
size := getSize(config.Storage.Path + "Packages")
if file == "Packages" && size == 0 {
Expand Down
1 change: 1 addition & 0 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func Register(w http.ResponseWriter, r *http.Request) {
return
} else if len(r.MultipartForm.Value["key"]) > 0 {
key := pgp.Verify("Hub", r.MultipartForm.Value["key"][0])
log.Debug(fmt.Sprintf("Key == %+v", r.MultipartForm.Value["key"]))
if len(key) == 0 {
log.Debug(fmt.Sprintf("Key empty"))
w.Write([]byte("Signature check failed"))
Expand Down
3 changes: 2 additions & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,10 @@ func RebuildShare(hash, owner string) {
func RegisterUser(name, key []byte) {
db.Update(func(tx *bolt.Tx) error {
b, err := tx.Bucket(Users).CreateBucketIfNotExists([]byte(strings.ToLower(string(name))))
if !log.Check(log.WarnLevel, "Registering user "+strings.ToLower(string(name)), err) {
if !log.Check(log.WarnLevel, "Registering user " + strings.ToLower(string(name)), err) {
b.Put([]byte("key"), key)
if b, err := b.CreateBucketIfNotExists([]byte("keys")); err == nil {
log.Debug(fmt.Sprintf("Created user %+v", name))
b.Put(key, nil)
}
}
Expand Down

0 comments on commit 41d3004

Please sign in to comment.