Skip to content

Commit 6e27622

Browse files
author
junoberryferry
committed
Use mholt/archives and fix #35387
1 parent dca375a commit 6e27622

File tree

5 files changed

+435
-89
lines changed

5 files changed

+435
-89
lines changed

cmd/dump.go

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"code.gitea.io/gitea/modules/util"
2121

2222
"gitea.com/go-chi/session"
23-
"github.com/mholt/archiver/v3"
2423
"github.com/urfave/cli/v3"
2524
)
2625

@@ -146,22 +145,10 @@ func runDump(ctx context.Context, cmd *cli.Command) error {
146145
return err
147146
}
148147

149-
archiverGeneric, err := archiver.ByExtension("." + outType)
150-
if err != nil {
151-
fatal("Unable to get archiver for extension: %v", err)
152-
}
153-
154-
archiverWriter := archiverGeneric.(archiver.Writer)
155-
if err := archiverWriter.Create(outFile); err != nil {
156-
fatal("Creating archiver.Writer failed: %v", err)
157-
}
158-
defer archiverWriter.Close()
159-
160-
dumper := &dump.Dumper{
161-
Writer: archiverWriter,
162-
Verbose: verbose,
163-
}
148+
dumper := dump.NewDumper(outType, outFile)
149+
dumper.Verbose = verbose
164150
dumper.GlobalExcludeAbsPath(outFileName)
151+
defer dumper.Close()
165152

166153
if cmd.IsSet("skip-repository") && cmd.Bool("skip-repository") {
167154
log.Info("Skip dumping local repositories")
@@ -322,10 +309,6 @@ func runDump(ctx context.Context, cmd *cli.Command) error {
322309
if outFileName == "-" {
323310
log.Info("Finish dumping to stdout")
324311
} else {
325-
if err = archiverWriter.Close(); err != nil {
326-
_ = os.Remove(outFileName)
327-
fatal("Failed to save %q: %v", outFileName, err)
328-
}
329312
if err = os.Chmod(outFileName, 0o600); err != nil {
330313
log.Info("Can't change file access permissions mask to 0600: %v", err)
331314
}

go.mod

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ require (
4040
github.com/dimiro1/reply v0.0.0-20200315094148-d0136a4c9e21
4141
github.com/djherbis/buffer v1.2.0
4242
github.com/djherbis/nio/v3 v3.0.1
43-
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5
43+
github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707
4444
github.com/dustin/go-humanize v1.0.1
4545
github.com/editorconfig/editorconfig-core-go/v2 v2.6.3
4646
github.com/emersion/go-imap v1.2.1
@@ -85,7 +85,7 @@ require (
8585
github.com/mattn/go-isatty v0.0.20
8686
github.com/mattn/go-sqlite3 v1.14.28
8787
github.com/meilisearch/meilisearch-go v0.31.0
88-
github.com/mholt/archiver/v3 v3.5.1
88+
github.com/mholt/archives v0.1.3
8989
github.com/microcosm-cc/bluemonday v1.0.27
9090
github.com/microsoft/go-mssqldb v1.8.0
9191
github.com/minio/minio-go/v7 v7.0.91
@@ -143,7 +143,8 @@ require (
143143
github.com/DataDog/zstd v1.5.7 // indirect
144144
github.com/Microsoft/go-winio v0.6.2 // indirect
145145
github.com/RoaringBitmap/roaring/v2 v2.4.5 // indirect
146-
github.com/andybalholm/brotli v1.1.1 // indirect
146+
github.com/STARRY-S/zip v0.2.1 // indirect
147+
github.com/andybalholm/brotli v1.1.2-0.20250424173009-453214e765f3 // indirect
147148
github.com/andybalholm/cascadia v1.3.3 // indirect
148149
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
149150
github.com/aws/aws-sdk-go-v2 v1.36.3 // indirect
@@ -171,6 +172,9 @@ require (
171172
github.com/blevesearch/zapx/v15 v15.4.1 // indirect
172173
github.com/blevesearch/zapx/v16 v16.2.3 // indirect
173174
github.com/bmatcuk/doublestar/v4 v4.8.1 // indirect
175+
github.com/bodgit/plumbing v1.3.0 // indirect
176+
github.com/bodgit/sevenzip v1.6.0 // indirect
177+
github.com/bodgit/windows v1.0.1 // indirect
174178
github.com/boombuler/barcode v1.0.2 // indirect
175179
github.com/bradfitz/gomemcache v0.0.0-20250403215159-8d39553ac7cf // indirect
176180
github.com/caddyserver/zerossl v0.1.3 // indirect
@@ -227,15 +231,17 @@ require (
227231
github.com/mattn/go-shellwords v1.0.12 // indirect
228232
github.com/mholt/acmez/v3 v3.1.2 // indirect
229233
github.com/miekg/dns v1.1.65 // indirect
234+
github.com/mikelolasagasti/xz v1.0.1 // indirect
230235
github.com/minio/crc64nvme v1.0.1 // indirect
231236
github.com/minio/md5-simd v1.1.2 // indirect
237+
github.com/minio/minlz v1.0.0 // indirect
232238
github.com/mitchellh/mapstructure v1.5.0 // indirect
233239
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
234240
github.com/modern-go/reflect2 v1.0.2 // indirect
235241
github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450 // indirect
236242
github.com/mschoch/smat v0.2.0 // indirect
237243
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
238-
github.com/nwaples/rardecode v1.1.3 // indirect
244+
github.com/nwaples/rardecode/v2 v2.1.0 // indirect
239245
github.com/olekukonko/tablewriter v0.0.5 // indirect
240246
github.com/onsi/ginkgo v1.16.5 // indirect
241247
github.com/pierrec/lz4/v4 v4.1.22 // indirect
@@ -250,6 +256,7 @@ require (
250256
github.com/russross/blackfriday/v2 v2.1.0 // indirect
251257
github.com/sirupsen/logrus v1.9.3 // indirect
252258
github.com/skeema/knownhosts v1.3.1 // indirect
259+
github.com/sorairolake/lzip-go v0.3.5 // indirect
253260
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
254261
github.com/unknwon/com v1.0.1 // indirect
255262
github.com/valyala/fastjson v1.6.4 // indirect
@@ -265,6 +272,7 @@ require (
265272
go.uber.org/multierr v1.11.0 // indirect
266273
go.uber.org/zap v1.27.0 // indirect
267274
go.uber.org/zap/exp v0.3.0 // indirect
275+
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
268276
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
269277
golang.org/x/mod v0.25.0 // indirect
270278
golang.org/x/time v0.11.0 // indirect
@@ -281,9 +289,6 @@ replace github.com/nektos/act => gitea.com/gitea/act v0.261.6
281289
// TODO: the only difference is in `PutObject`: the fork doesn't use `NewVerifyingReader(r, sha256.New(), oid, expectedSize)`, need to figure out why
282290
replace github.com/charmbracelet/git-lfs-transfer => gitea.com/gitea/git-lfs-transfer v0.2.0
283291

284-
// TODO: This could be removed after https://github.com/mholt/archiver/pull/396 merged
285-
replace github.com/mholt/archiver/v3 => github.com/anchore/archiver/v3 v3.5.2
286-
287292
replace git.sr.ht/~mariusor/go-xsd-duration => gitea.com/gitea/go-xsd-duration v0.0.0-20220703122237-02e73435a078
288293

289294
exclude github.com/gofrs/uuid v3.2.0+incompatible

0 commit comments

Comments
 (0)