mirror of
https://github.com/hanzoai/s3.git
synced 2026-10-30 14:59:09 +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.
98 lines
4.0 KiB
Lua
98 lines
4.0 KiB
Lua
box.watch('box.status', function()
|
|
if box.info.ro then
|
|
return
|
|
end
|
|
|
|
-- ====================================
|
|
-- key_value space
|
|
-- ====================================
|
|
box.schema.create_space('key_value', {
|
|
format = {
|
|
{ name = 'key', type = 'string' },
|
|
{ name = 'bucket_id', type = 'unsigned' },
|
|
{ name = 'value', type = 'string' }
|
|
},
|
|
if_not_exists = true
|
|
})
|
|
|
|
-- create key_value space indexes
|
|
box.space.key_value:create_index('id', {type = 'tree', parts = { 'key' }, unique = true, if_not_exists = true})
|
|
box.space.key_value:create_index('bucket_id', { type = 'tree', parts = { 'bucket_id' }, unique = false, if_not_exists = true })
|
|
|
|
-- ====================================
|
|
-- filer_metadata space
|
|
-- ====================================
|
|
box.schema.create_space('filer_metadata', {
|
|
format = {
|
|
{ name = 'directory', type = 'string' },
|
|
{ name = 'bucket_id', type = 'unsigned' },
|
|
{ name = 'name', type = 'string' },
|
|
{ name = 'expire_at', type = 'unsigned' },
|
|
{ name = 'data', type = 'string' }
|
|
},
|
|
if_not_exists = true
|
|
})
|
|
|
|
-- create filer_metadata space indexes
|
|
box.space.filer_metadata:create_index('id', {type = 'tree', parts = { 'directory', 'name' }, unique = true, if_not_exists = true})
|
|
box.space.filer_metadata:create_index('bucket_id', { type = 'tree', parts = { 'bucket_id' }, unique = false, if_not_exists = true })
|
|
box.space.filer_metadata:create_index('directory_idx', { type = 'tree', parts = { 'directory' }, unique = false, if_not_exists = true })
|
|
box.space.filer_metadata:create_index('name_idx', { type = 'tree', parts = { 'name' }, unique = false, if_not_exists = true })
|
|
box.space.filer_metadata:create_index('expire_at_idx', { type = 'tree', parts = { 'expire_at' }, unique = false, if_not_exists = true})
|
|
end)
|
|
|
|
-- functions for filer_metadata space
|
|
local filer_metadata = {
|
|
delete_by_directory_idx = function(directory)
|
|
local space = box.space.filer_metadata
|
|
local index = space.index.directory_idx
|
|
-- for each finded directories
|
|
for _, tuple in index:pairs({ directory }, { iterator = 'EQ' }) do
|
|
space:delete({ tuple[1], tuple[3] })
|
|
end
|
|
return true
|
|
end,
|
|
find_by_directory_idx_and_name = function(dirPath, startFileName, includeStartFile, limit)
|
|
local space = box.space.filer_metadata
|
|
local directory_idx = space.index.directory_idx
|
|
-- choose filter name function
|
|
local filter_filename_func
|
|
if includeStartFile then
|
|
filter_filename_func = function(value) return value >= startFileName end
|
|
else
|
|
filter_filename_func = function(value) return value > startFileName end
|
|
end
|
|
-- init results
|
|
local results = {}
|
|
-- for each finded directories
|
|
for _, tuple in directory_idx:pairs({ dirPath }, { iterator = 'EQ' }) do
|
|
-- filter by name
|
|
if filter_filename_func(tuple[3]) then
|
|
table.insert(results, tuple)
|
|
end
|
|
end
|
|
-- sort
|
|
table.sort(results, function(a, b) return a[3] < b[3] end)
|
|
-- apply limit
|
|
if #results > limit then
|
|
local limitedResults = {}
|
|
for i = 1, limit do
|
|
table.insert(limitedResults, results[i])
|
|
end
|
|
results = limitedResults
|
|
end
|
|
-- return
|
|
return results
|
|
end,
|
|
is_expired = function(args, tuple)
|
|
return (tuple[4] > 0) and (require('fiber').time() > tuple[4])
|
|
end
|
|
}
|
|
|
|
-- register functions for filer_metadata space, set grants
|
|
rawset(_G, 'filer_metadata', filer_metadata)
|
|
for name, _ in pairs(filer_metadata) do
|
|
box.schema.func.create('filer_metadata.' .. name, { setuid = true, if_not_exists = true })
|
|
box.schema.user.grant('storage', 'execute', 'function', 'filer_metadata.' .. name, { if_not_exists = true })
|
|
end
|