Fix issues found by staticcheck. NFC

This commit is contained in:
Catherine
2025-09-20 03:55:58 +00:00
parent 9f0e54546a
commit 412c2c2e3a
2 changed files with 3 additions and 23 deletions

View File

@@ -40,7 +40,7 @@ func CompareManifest(left *Manifest, right *Manifest) bool {
if leftEntry.GetType() != rightEntry.GetType() {
return false
}
if bytes.Compare(leftEntry.Data, rightEntry.Data) != 0 {
if !bytes.Equal(leftEntry.Data, rightEntry.Data) {
return false
}
}
@@ -74,7 +74,7 @@ func ManifestDebugJSON(manifest *Manifest) []byte {
const maxSymlinkLevels int = 128
var symlinkLoop = errors.New("symbolic link loop")
var errSymlinkLoop = errors.New("symbolic link loop")
func ExpandSymlinks(manifest *Manifest, inPath string) (string, error) {
var levels int
@@ -98,7 +98,7 @@ again:
if levels < maxSymlinkLevels {
return inPath, nil
} else {
return "", symlinkLoop
return "", errSymlinkLoop
}
}

View File

@@ -160,26 +160,6 @@ func getPage(w http.ResponseWriter, r *http.Request) error {
return nil
}
func getProjectName(w http.ResponseWriter, r *http.Request) (string, error) {
// path must be either `/` or `/foo/` (`/foo` is accepted as an alias)
path, _ := strings.CutPrefix(r.URL.Path, "/")
path, _ = strings.CutSuffix(path, "/")
if strings.HasPrefix(path, ".") {
http.Error(w, "this directory name is reserved for system use", http.StatusBadRequest)
return "", fmt.Errorf("reserved name")
} else if strings.Contains(path, "/") {
http.Error(w, "only one level of nesting is allowed", http.StatusBadRequest)
return "", fmt.Errorf("nesting too deep")
}
if path == "" {
// path `/` corresponds to pseudo-project `.index`
return ".index", nil
} else {
return path, nil
}
}
func putPage(w http.ResponseWriter, r *http.Request) error {
auth, err := AuthorizeUpdate(r)
if err != nil {