Skip to content

Commit

Permalink
pnfsmanager: fix digest name handling in get file checksum command
Browse files Browse the repository at this point in the history
Motivation:
dcache's admin command builder can convert string values into
corresponding enum values. This works well for cases where enum name and
string name are the same, like "ADLER32" and ADLER32. However it's not
always the case: "MD5" and MD5_TYPE.

Modification:
update `get file checksum` command to accept string as an argument and
use  ChecksumType#getChecksumType method to convert digest name to a
corresponding ChecksumType enum.

Result:
`get file checksum` works as expected.

Fixes: #4064
Acked-by: Paul Millar
Target: master, 4.2, 4.1, 4.0, 3.2
Require-book: no
Require-notes: no
  • Loading branch information
kofemann committed Jul 3, 2018
1 parent c3f1b22 commit 9914d17
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -867,11 +867,12 @@ public class GetFileChecksumCommand implements Callable<String>
@Argument(index = 1,
usage = "The checksums type of the file. These following checksums " +
"are supported: adler32, md5 and md4.")
ChecksumType type;
String typeArg;

@Override
public String call() throws CacheException, NoSuchAlgorithmException
{
ChecksumType type = ChecksumType.getChecksumType(typeArg);
return getChecksums(ROOT, pnfsId).stream()
.filter(c -> c.getType() == type)
.map(Checksum::toString)
Expand Down

0 comments on commit 9914d17

Please sign in to comment.