teldrive/pkg/mapper/mapper.go
divyam234 110a821836
feat: enhance check command with dry-run and verbose logging
- 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
2025-12-24 10:37:46 +05:30

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),
}
})
}