Initial commit: Open sourcing all of the Maple Open Technologies code.

This commit is contained in:
Bartlomiej Mika 2025-12-02 14:33:08 -05:00
commit 755d54a99d
2010 changed files with 448675 additions and 0 deletions

View file

@ -0,0 +1,48 @@
// monorepo/cloud/maplefile-backend/internal/maplefile/repo/filemetadata/restore.go
package filemetadata
import (
"fmt"
"time"
"github.com/gocql/gocql"
"go.uber.org/zap"
dom_file "codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/internal/domain/file"
)
func (impl *fileMetadataRepositoryImpl) Restore(id gocql.UUID) error {
file, err := impl.Get(id)
if err != nil {
return fmt.Errorf("failed to get file for restore: %w", err)
}
if file == nil {
return fmt.Errorf("file not found")
}
// Validate state transition
if err := dom_file.IsValidStateTransition(file.State, dom_file.FileStateActive); err != nil {
return fmt.Errorf("invalid state transition: %w", err)
}
// Update file state
file.State = dom_file.FileStateActive
file.ModifiedAt = time.Now()
file.Version++
file.TombstoneVersion = 0
file.TombstoneExpiry = time.Time{}
return impl.Update(file)
}
func (impl *fileMetadataRepositoryImpl) RestoreMany(ids []gocql.UUID) error {
for _, id := range ids {
if err := impl.Restore(id); err != nil {
impl.Logger.Warn("failed to restore file",
zap.String("file_id", id.String()),
zap.Error(err))
}
}
return nil
}