( stor storage.Storage, path string, file tfile.TGFile, )
| 49 | } |
| 50 | |
| 51 | func NewTaskElement( |
| 52 | stor storage.Storage, |
| 53 | path string, |
| 54 | file tfile.TGFile, |
| 55 | ) (*TaskElement, error) { |
| 56 | id := xid.New().String() |
| 57 | _, ok := stor.(storage.StorageCannotStream) |
| 58 | if !config.C().Stream || ok { |
| 59 | cachePath, err := filepath.Abs(filepath.Join(config.C().Temp.BasePath, fmt.Sprintf("%s_%s", id, file.Name()))) |
| 60 | if err != nil { |
| 61 | return nil, fmt.Errorf("failed to get absolute path for cache: %w", err) |
| 62 | } |
| 63 | return &TaskElement{ |
| 64 | ID: id, |
| 65 | Storage: stor, |
| 66 | Path: path, |
| 67 | File: file, |
| 68 | localPath: cachePath, |
| 69 | }, nil |
| 70 | } |
| 71 | return &TaskElement{ |
| 72 | ID: id, |
| 73 | Storage: stor, |
| 74 | Path: path, |
| 75 | File: file, |
| 76 | stream: true, |
| 77 | }, nil |
| 78 | } |
| 79 | |
| 80 | func NewBatchTGFileTask( |
| 81 | id string, |
no test coverage detected