Initial commit: Open sourcing all of the Maple Open Technologies code.
This commit is contained in:
commit
755d54a99d
2010 changed files with 448675 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
// monorepo/cloud/maplefile-backend/internal/maplefile/repo/filemetadata/archive.go
|
||||
package filemetadata
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gocql/gocql"
|
||||
dom_file "codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/internal/domain/file"
|
||||
)
|
||||
|
||||
func (impl *fileMetadataRepositoryImpl) Archive(id gocql.UUID) error {
|
||||
file, err := impl.Get(id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get file for archive: %w", err)
|
||||
}
|
||||
|
||||
if file == nil {
|
||||
return fmt.Errorf("file not found")
|
||||
}
|
||||
|
||||
// Validate state transition
|
||||
if err := dom_file.IsValidStateTransition(file.State, dom_file.FileStateArchived); err != nil {
|
||||
return fmt.Errorf("invalid state transition: %w", err)
|
||||
}
|
||||
|
||||
// Update file state
|
||||
file.State = dom_file.FileStateArchived
|
||||
file.ModifiedAt = time.Now()
|
||||
file.Version++
|
||||
|
||||
return impl.Update(file)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue