@@ -20,10 +20,15 @@ const (
20
20
minSize int64 = 4 * 1024
21
21
)
22
22
23
+ var (
24
+ version = "undefined"
25
+ buildTime = "unknown"
26
+ )
27
+
23
28
type context struct {
24
29
pathstore storage.PathStorage
25
- stats * storage.Statistics
26
- state storage.DedupInterface
30
+ stats * storage.Statistics
31
+ state storage.DedupInterface
27
32
}
28
33
29
34
// readDirNames reads the directory named by dirname
@@ -168,14 +173,14 @@ func submitForDedup(ctx context, files []*storage.FileInformation, noact bool) {
168
173
filenames [i ] = ctx .pathstore .FilePath (file .Path )
169
174
}
170
175
if sameOffset {
171
- log .Printf ("Skipping %s and %d other files, they all have the same physical offset" , filenames [0 ], len (files )- 1 )
176
+ log .Printf ("Skipping %s and %d other files, they all have the same physical offset" , filenames [0 ], len (files ) - 1 )
172
177
return
173
178
}
174
179
if ! noact {
175
- log .Printf ("Offering for deduplication: %s and %d other files\n " , filenames [0 ], len (files )- 1 )
180
+ log .Printf ("Offering for deduplication: %s and %d other files\n " , filenames [0 ], len (files ) - 1 )
176
181
Dedup (filenames , 0 , uint64 (size ))
177
182
} else {
178
- log .Printf ("Candidate for deduplication: %s and %d other files\n " , filenames [0 ], len (files )- 1 )
183
+ log .Printf ("Candidate for deduplication: %s and %d other files\n " , filenames [0 ], len (files ) - 1 )
179
184
}
180
185
}
181
186
@@ -255,13 +260,19 @@ func main() {
255
260
fmt .Fprintf (os .Stderr , "Usage: %s [OPTION]... [FILE-OR-DIR]...\n " , os .Args [0 ])
256
261
flag .PrintDefaults ()
257
262
}
263
+ showVersion := flag .Bool ("version" , false , "show version information and exits" )
258
264
noact := flag .Bool ("noact" , false , "if provided, the tool will only scan and log results, but not actually deduplicate" )
259
265
lowmem := flag .Bool ("lowmem" , false , "if provided, the tool will use much less memory by using temporary files and the external sort command" )
260
266
nopb := flag .Bool ("nopb" , false , "if provided, the tool will not show the progress bar" )
261
267
cpuprofile := flag .String ("cpuprofile" , "" , "write cpu profile to file" )
262
268
memprofile := flag .String ("memprofile" , "" , "write memory profile to this file" )
263
269
flag .Parse ()
264
270
271
+ if * showVersion {
272
+ fmt .Printf ("btrdedup version '%s' built at '%s'\n " , version , buildTime )
273
+ return
274
+ }
275
+
265
276
if * cpuprofile != "" {
266
277
f , err := os .Create ((* cpuprofile ) + ".prof" )
267
278
if err != nil {
0 commit comments