MCPcopy Create free account
hub / github.com/driangle/taskmd / executeArchive

Function executeArchive

apps/cli/internal/cli/archive.go:224–251  ·  view source on GitHub ↗
(tasks []*model.Task, absScanDir string)

Source from the content-addressed store, hash-verified

222}
223
224func executeArchive(tasks []*model.Task, absScanDir string) error {
225 r := getRenderer()
226 archiveDir := filepath.Join(absScanDir, "archive")
227
228 for _, task := range tasks {
229 relPath, err := filepath.Rel(absScanDir, task.FilePath)
230 if err != nil {
231 return fmt.Errorf("failed to compute relative path for %s: %w", task.FilePath, err)
232 }
233
234 destPath := filepath.Join(archiveDir, relPath)
235
236 if err := os.MkdirAll(filepath.Dir(destPath), 0755); err != nil {
237 return fmt.Errorf("failed to create archive directory: %w", err)
238 }
239
240 if _, err := os.Stat(destPath); err == nil {
241 return fmt.Errorf("archive destination already exists: %s", destPath)
242 }
243
244 if err := os.Rename(task.FilePath, destPath); err != nil {
245 return fmt.Errorf("failed to move %s: %w", task.FilePath, err)
246 }
247 }
248
249 fmt.Println(formatSuccess(fmt.Sprintf("Archived %d task(s).", len(tasks)), r))
250 return nil
251}

Callers 1

runArchiveFunction · 0.85

Calls 2

getRendererFunction · 0.85
formatSuccessFunction · 0.85

Tested by

no test coverage detected