mirror of
https://github.com/hanzoai/s3.git
synced 2026-11-03 03:07:41 +00:00
hanzoai/s3 was an AGPL-3.0 MinIO fork whose network-copyleft blocks embedding
and reselling as a managed service. Replace it wholesale with a fork of
SeaweedFS (github.com/seaweedfs/seaweedfs, Apache-2.0, Go) which ships a
built-in S3 gateway + Filer.
- License: AGPL-3.0 -> Apache-2.0 (upstream LICENSE kept verbatim, incl.
"Copyright 2025 Chris Lu"); NOTICE added crediting SeaweedFS. No AGPL/BUSL/
SSPL/GPL or enterprise ("ee") files remain.
- Module: go.mod path set to github.com/hanzoai/s3 with a self-replace
(replace github.com/seaweedfs/seaweedfs => ./) so the ~1800 internal Go files
keep their upstream import paths with zero churn. Internal identifiers and
import paths are intentionally NOT renamed.
- CLI rebrand: the binary is built as `s3` (was `weed`); root usage, per-command
help/usage/flag strings, shell autocomplete program name, and the product name
in CLI output now read "Hanzo S3" / `s3`. Users never see `weed`.
(e.g. `s3 server`, `s3 filer`, `s3 master`, `s3 volume`, `s3 s3`, `s3 mount`.)
- Build: `make` (or `go build -o s3 ./weed`) builds the `s3` binary green;
`cmd/weed-db` and `cmd/weed-sql` also build; `go vet ./weed/command/` clean.
- README/LLM.md rewritten for Hanzo S3; AGENTS.md/CLAUDE.md symlinks preserved.
- Dropped a 33MB prebuilt Mach-O `stress` binary upstream had committed; `.gitignore`
updated to ignore the `s3` build output.
104 lines
2.5 KiB
Go
104 lines
2.5 KiB
Go
package idx
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"sort"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
|
)
|
|
|
|
type indexEntry struct {
|
|
index int
|
|
id types.NeedleId
|
|
offset int64
|
|
size types.Size
|
|
}
|
|
|
|
func (ie *indexEntry) Compare(other *indexEntry) int {
|
|
if ie.offset < other.offset {
|
|
return -1
|
|
}
|
|
if ie.offset > other.offset {
|
|
return 1
|
|
}
|
|
if ie.size < other.size {
|
|
return -1
|
|
}
|
|
if ie.size > other.size {
|
|
return 1
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// CheckIndexFile verifies the integrity of a IDX/ECX index file. Returns a count of processed file entries, and slice of found errors.
|
|
func CheckIndexFile(r io.ReaderAt, indexFileSize int64, version needle.Version) (int64, []error) {
|
|
errs := []error{}
|
|
|
|
entries := []*indexEntry{}
|
|
var i int
|
|
err := WalkIndexFile(r, 0, func(id types.NeedleId, offset types.Offset, size types.Size) error {
|
|
entries = append(entries, &indexEntry{
|
|
index: i,
|
|
id: id,
|
|
offset: offset.ToActualOffset(),
|
|
size: size,
|
|
})
|
|
i++
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
errs = append(errs, err)
|
|
}
|
|
|
|
sort.Slice(entries, func(i, j int) bool {
|
|
return entries[i].Compare(entries[j]) < 0
|
|
})
|
|
|
|
for i, e := range entries {
|
|
if i == 0 {
|
|
// nothing to check for the first entry
|
|
continue
|
|
}
|
|
|
|
start, end := e.offset, e.offset
|
|
if size := needle.GetActualSize(e.size, version); size != 0 {
|
|
end += size - 1
|
|
}
|
|
|
|
last := entries[i-1]
|
|
lastStart, lastEnd := last.offset, last.offset
|
|
if lastSize := needle.GetActualSize(last.size, version); lastSize != 0 {
|
|
lastEnd += lastSize - 1
|
|
}
|
|
|
|
// check if needles overlap
|
|
if start <= lastEnd {
|
|
errs = append(errs, fmt.Errorf(
|
|
"needle %d (#%d) at [%d-%d] overlaps needle %d at [%d-%d]",
|
|
e.id, e.index+1,
|
|
start, end,
|
|
last.id,
|
|
lastStart, lastEnd))
|
|
}
|
|
|
|
// The check below is intended to ensure all index entries are contiguous; unfortunately, Seaweed
|
|
// can delete index entries for files while keeping their data, so volumes with deleted files
|
|
// will fail this test :(
|
|
// See https://github.com/seaweedfs/seaweedfs/issues/8204 for details.
|
|
/*
|
|
if e.offset != lastEnd + 1 {
|
|
errs = append(errs, fmt.Errorf("offset %d for needle %d (#%d) doesn't match end of needle %d at %d", e.offset, e.id, e.index+1, last.id, lastEnd))
|
|
}
|
|
*/
|
|
}
|
|
|
|
count := int64(len(entries))
|
|
if got, want := count*types.NeedleMapEntrySize, indexFileSize; got != want {
|
|
errs = append(errs, fmt.Errorf("expected an index file of size %d, got %d", want, got))
|
|
}
|
|
|
|
return count, errs
|
|
}
|