Skip to content

Commit

Permalink
Remove unneeded [Fingerprint.string]
Browse files Browse the repository at this point in the history
Usage of [Fingerprint.string] in archive names is incorrect - archive
names are based on MD5 which may or may not be the same as the file
fingerprinting algorithm.

The other use of [Fingerprint.string] is in debug output of tests, where
it's used to debug the test framework itself. Remove this usage for now.

As such, [Fingerprint.string] becomes unused and can be removed.
  • Loading branch information
tleedjarv committed Sep 26, 2023
1 parent 893b380 commit 9a41cab
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 11 deletions.
3 changes: 0 additions & 3 deletions src/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,6 @@ test.cmo : \
globals.cmi \
fspath.cmi \
fs.cmi \
fingerprint.cmi \
common.cmi \
test.cmi
test.cmx : \
Expand Down Expand Up @@ -1516,7 +1515,6 @@ update.cmo : \
fswatch.cmi \
fspath.cmi \
fpcache.cmi \
fingerprint.cmi \
fileinfo.cmi \
features.cmi \
common.cmi \
Expand Down Expand Up @@ -1549,7 +1547,6 @@ update.cmx : \
fswatch.cmx \
fspath.cmx \
fpcache.cmx \
fingerprint.cmx \
fileinfo.cmx \
features.cmx \
common.cmx \
Expand Down
2 changes: 0 additions & 2 deletions src/fingerprint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ let toString md5 =
Bytes.to_string string
end

let string = Digest.string

let dummy = ""

let hash d =
Expand Down
2 changes: 0 additions & 2 deletions src/fingerprint.mli
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ val m : t Umarshal.t
val file : Fspath.t -> Path.local -> t
val subfile : Fspath.t -> Int64.t -> Uutil.Filesize.t -> t

val string : string -> t

val toString : t -> string

(* This dummy fingerprint is guaranteed small and distinct from all
Expand Down
4 changes: 2 additions & 2 deletions src/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ let writefs p fs =
verbose (fun() -> Util.msg "Writing new test filesystem\n");
let rec loop p = function
| File s ->
verbose (fun() -> Util.msg "Writing %s with contents %s (fingerprint %s)\n"
(Fspath.toDebugString p) s (Fingerprint.toString (Fingerprint.string s)));
verbose (fun() -> Util.msg "Writing %s with contents %s\n"
(Fspath.toDebugString p) s);
write p s
| Link s -> Fs.symlink s p
| Dir files ->
Expand Down
4 changes: 2 additions & 2 deletions src/update.ml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ let archiveHash fspath =
let thisRoot = thisRootsGlobalName fspath in
let r = Prefs.read rootsName in
let n = Printf.sprintf "%s;%s;%d" thisRoot r archiveFormat in
let d = Fingerprint.toString (Fingerprint.string n) in
let d = Digest.to_hex (Digest.string n) in
debugverbose (fun()-> Util.msg "Archive name is %s; hashcode is %s\n" n d);
if Prefs.read showArchiveName then
Util.msg "Archive name is %s; hashcode is %s\n" n d;
Expand Down Expand Up @@ -282,7 +282,7 @@ let archiveName251 fspath (v: archiveVersion): string * string =
let thisRoot = thisRootsGlobalName fspath in
let r = Prefs.read rootsName in
let n = Printf.sprintf "%s;%s;22" thisRoot r in
let d = Fingerprint.toString (Fingerprint.string n) in
let d = Digest.to_hex (Digest.string n) in
(String.sub d 0 significantDigits)
in
let n = archiveHash251 fspath in
Expand Down

0 comments on commit 9a41cab

Please sign in to comment.