MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / Reduce

Method Reduce

agent/app/service/recycle_bin.go:143–171  ·  view source on GitHub ↗
(reduce request.RecycleBinReduce)

Source from the content-addressed store, hash-verified

141}
142
143func (r RecycleBinService) Reduce(reduce request.RecycleBinReduce) error {
144 filePath := path.Join(reduce.From, reduce.RName)
145 op := files.NewFileOp()
146 if !op.Stat(filePath) {
147 return buserr.New("ErrLinkPathNotFound")
148 }
149 recycleBinDTO, err := loadRecycleBinDTO(reduce.From, reduce.RName)
150 if err != nil {
151 return err
152 }
153 if recycleBinDTO.SourcePath == "" {
154 return buserr.New("ErrSourcePathNotFound")
155 }
156 if !op.Stat(path.Dir(recycleBinDTO.SourcePath)) {
157 return buserr.New("ErrSourcePathNotFound")
158 }
159 if op.Stat(recycleBinDTO.SourcePath) {
160 if err = op.RmRf(recycleBinDTO.SourcePath); err != nil {
161 return err
162 }
163 }
164 if err := op.Mv(filePath, recycleBinDTO.SourcePath); err != nil {
165 return err
166 }
167 if err := cleanupTrashInfoByEntryPath(filePath); err != nil {
168 global.LOG.Warnf("cleanup trashinfo failed for %s: %v", filePath, err)
169 }
170 return nil
171}
172
173func (r RecycleBinService) Clear() error {
174 partitions, err := disk.Partitions(false)

Callers

nothing calls this directly

Calls 5

StatMethod · 0.95
RmRfMethod · 0.95
MvMethod · 0.95
loadRecycleBinDTOFunction · 0.85

Tested by

no test coverage detected