MCPcopy Create free account
hub / github.com/gogs/gogs / addCustomDirToBackup

Function addCustomDirToBackup

internal/cmd/backup.go:166–194  ·  view source on GitHub ↗
(z *zip.ZipArchive)

Source from the content-addressed store, hash-verified

164}
165
166func addCustomDirToBackup(z *zip.ZipArchive) error {
167 customDir := conf.CustomDir()
168 entries, err := os.ReadDir(customDir)
169 if err != nil {
170 return errors.Wrap(err, "list custom directory entries")
171 }
172
173 for _, e := range entries {
174 if e.Name() == "data" {
175 // Skip the "data" directory because it lives under the "custom" directory in
176 // the Docker setup and will be backed up separately.
177 log.Trace(`Skipping "data" directory in custom directory`)
178 continue
179 }
180
181 add := z.AddFile
182 if e.IsDir() {
183 add = z.AddDir
184 }
185 err = add(
186 fmt.Sprintf("%s/custom/%s", archiveRootDir, e.Name()),
187 filepath.Join(customDir, e.Name()),
188 )
189 if err != nil {
190 return errors.Wrapf(err, "add %q", e.Name())
191 }
192 }
193 return nil
194}

Callers 1

runBackupFunction · 0.85

Calls 3

CustomDirFunction · 0.92
addFunction · 0.50
NameMethod · 0.45

Tested by

no test coverage detected