feat: add browser upload queue and trusted sessions with bounded projections
Build and publish container images / images (push) Successful in 11m37s
Release container images / release (push) Successful in 22s

This commit is contained in:
Anya Tokugawa committed 2026-11-08 20:27:04 +09:00
1 parent 84d52390f9
commit b90aef79d0
79 files changed
+1962 -196

No files matched your search

+21 -2
View File
@@ -39,6 +39,7 @@ func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusRequestEntityTooLarge)
return
}
defer r.MultipartForm.RemoveAll()
file, header, err := r.FormFile("file")
if err != nil {
http.Error(w, "file is required", http.StatusBadRequest)
@@ -83,6 +84,11 @@ func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) {
}
}
objectUUID, err := s.store.ResolvePathInDomain(domainUUID, targetPath)
createOnly := r.Header.Get("If-None-Match") == "*"
if err == nil && createOnly {
http.Error(w, "file already exists", http.StatusPreconditionFailed)
return
}
if err == nil && mode == "enforcing" {
// upload and write-once grants never overwrite an existing object.
if s.store.Authorize(store.AuthorizationRequest{DomainUUID: domainUUID, PrincipalUUID: principal.UUID, Capability: "write", TargetType: "path", TargetID: targetPath}) != nil {
@@ -92,6 +98,13 @@ func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) {
}
if errors.Is(err, sql.ErrNoRows) {
objectUUID, err = s.store.CreatePageAtPathInDomain(domainUUID, targetPath)
if err != nil && createOnly {
// A concurrent creator wins; never turn this into an overwrite.
if _, resolveErr := s.store.ResolvePathInDomain(domainUUID, targetPath); resolveErr == nil {
http.Error(w, "file already exists", http.StatusPreconditionFailed)
return
}
}
}
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
@@ -113,17 +126,23 @@ func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) {
if strings.TrimSpace(language) == "" {
language = "und"
}
if _, err := s.store.SaveRevisionContent(
revision, err := s.store.SaveRevisionContent(
objectUUID,
payload,
"web upload: "+originalName,
language,
contentType,
originalName,
); err != nil {
)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if strings.Contains(r.Header.Get("Accept"), "application/json") {
w.Header().Set("Cache-Control", "private, no-store")
writeEventJSON(w, http.StatusCreated, map[string]string{"path": targetPath, "object_uuid": objectUUID, "revision_uuid": revision.UUID})
return
}
http.Redirect(w, r, targetPath, http.StatusSeeOther)
}