MCPcopy
hub / github.com/OpenListTeam/OpenList / RunWithoutPushUploadTask

Method RunWithoutPushUploadTask

internal/fs/archive.go:66–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64}
65
66func (t *ArchiveDownloadTask) RunWithoutPushUploadTask() (*ArchiveContentUploadTask, error) {
67 srcObj, tool, ss, err := op.GetArchiveToolAndStream(t.Ctx(), t.SrcStorage, t.SrcActualPath, model.LinkArgs{})
68 if err != nil {
69 return nil, err
70 }
71 defer func() {
72 var e error
73 for _, s := range ss {
74 e = stderrors.Join(e, s.Close())
75 }
76 if e != nil {
77 log.Errorf("failed to close file streamer, %v", e)
78 }
79 }()
80 var decompressUp model.UpdateProgress
81 if t.CacheFull {
82 total := int64(0)
83 for _, s := range ss {
84 total += s.GetSize()
85 }
86 t.SetTotalBytes(total)
87 t.Status = "getting src object"
88 part := 100 / float64(len(ss)+1)
89 for i, s := range ss {
90 if s.GetFile() != nil {
91 continue
92 }
93 _, err = s.CacheFullAndWriter(nil, nil)
94 if err != nil {
95 return nil, err
96 } else {
97 t.SetProgress(float64(i+1) * part)
98 }
99 }
100 decompressUp = model.UpdateProgressWithRange(t.SetProgress, 100-part, 100)
101 } else {
102 decompressUp = t.SetProgress
103 }
104 t.Status = "walking and decompressing"
105 dir, err := os.MkdirTemp(conf.Conf.TempDir, "dir-*")
106 if err != nil {
107 return nil, err
108 }
109 err = tool.Decompress(ss, dir, t.ArchiveInnerArgs, decompressUp)
110 if err != nil {
111 return nil, err
112 }
113 baseName := strings.TrimSuffix(srcObj.GetName(), stdpath.Ext(srcObj.GetName()))
114 uploadTask := &ArchiveContentUploadTask{
115 TaskExtension: task.TaskExtension{
116 Creator: t.Creator,
117 ApiUrl: t.ApiUrl,
118 },
119 ObjName: baseName,
120 InPlace: !t.PutIntoNewDir,
121 FilePath: dir,
122 DstActualPath: t.DstActualPath,
123 dstStorage: t.DstStorage,

Callers 2

RunMethod · 0.95
archiveDecompressFunction · 0.95

Calls 10

GetArchiveToolAndStreamFunction · 0.92
UpdateProgressWithRangeFunction · 0.92
SetTotalBytesMethod · 0.80
SetProgressMethod · 0.80
CloseMethod · 0.65
GetSizeMethod · 0.65
GetFileMethod · 0.65
CacheFullAndWriterMethod · 0.65
DecompressMethod · 0.65
GetNameMethod · 0.65

Tested by

no test coverage detected