mirror of
https://github.com/tgdrive/teldrive.git
synced 2026-01-20 07:49:21 +08:00
- Add --dry-run flag to simulate check/clean without changes - Add --verbose flag for detailed logging and debugging - Add comprehensive summary output showing files checked, missing, orphans - Rename --export to --export-file with custom path support - Improve error messages with channel-specific context - Add YAML configuration support with config.sample.yml - Refactor reader for concurrent chunk fetching with buffer management - Add config loader tests - Update dependencies (gotd/td, gocron, redis, opentelemetry, etc.) - Fix RegisterPlags typo to RegisterFlags in cmd/run.go
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package mapper
|
|
|
|
import (
|
|
"github.com/tgdrive/teldrive/internal/api"
|
|
"github.com/tgdrive/teldrive/internal/utils"
|
|
"github.com/tgdrive/teldrive/pkg/models"
|
|
)
|
|
|
|
func ToFileOut(file models.File) *api.File {
|
|
res := &api.File{
|
|
ID: api.NewOptString(file.ID),
|
|
Name: file.Name,
|
|
Type: api.FileType(file.Type),
|
|
MimeType: api.NewOptString(file.MimeType),
|
|
Encrypted: api.NewOptBool(*file.Encrypted),
|
|
UpdatedAt: api.NewOptDateTime(*file.UpdatedAt),
|
|
}
|
|
if file.ParentId != nil {
|
|
res.ParentId = api.NewOptString(*file.ParentId)
|
|
}
|
|
if file.Size != nil {
|
|
res.Size = api.NewOptInt64(*file.Size)
|
|
}
|
|
if file.Category != nil && *file.Category != "" {
|
|
res.Category = api.NewOptCategory(api.Category(*file.Category))
|
|
}
|
|
return res
|
|
}
|
|
|
|
func ToUploadOut(parts []models.Upload) []api.UploadPart {
|
|
return utils.Map(parts, func(part models.Upload) api.UploadPart {
|
|
return api.UploadPart{
|
|
Name: part.Name,
|
|
PartId: part.PartId,
|
|
ChannelId: part.ChannelId,
|
|
PartNo: part.PartNo,
|
|
Size: part.Size,
|
|
Encrypted: part.Encrypted,
|
|
Salt: api.NewOptString(part.Salt),
|
|
}
|
|
})
|
|
}
|