From 3a48fc87a3791fd92d0e554a8fd87cdbbc9e8d2c Mon Sep 17 00:00:00 2001 From: David Richey Date: Fri, 9 Aug 2024 07:28:56 -0700 Subject: [PATCH] Only copy large binary files Summary: If an input to `glean merge` is already larger than the specified max merged file size, it will just copy it to the output. If the input is in json format, then this causes merge to output json which is unexpected. Only perform the copy if the input is in binary format. Reviewed By: malanka Differential Revision: D60988559 fbshipit-source-id: a8e1ffbe1d152ace95def3884d1d53896d016bef --- glean/tools/gleancli/GleanCLI/Common.hs | 1 + glean/tools/gleancli/GleanCLI/Merge.hs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/glean/tools/gleancli/GleanCLI/Common.hs b/glean/tools/gleancli/GleanCLI/Common.hs index 4e5ea0ea8..2417e3398 100644 --- a/glean/tools/gleancli/GleanCLI/Common.hs +++ b/glean/tools/gleancli/GleanCLI/Common.hs @@ -99,6 +99,7 @@ handleOpt = textOption data FileFormat = JsonFormat | BinaryFormat + deriving (Eq) instance Show FileFormat where show ff = case ff of diff --git a/glean/tools/gleancli/GleanCLI/Merge.hs b/glean/tools/gleancli/GleanCLI/Merge.hs index 51507ffe3..6fe48e936 100644 --- a/glean/tools/gleancli/GleanCLI/Merge.hs +++ b/glean/tools/gleancli/GleanCLI/Merge.hs @@ -160,7 +160,8 @@ instance Plugin MergeCommand where loop !n _ (Just set) [] = write (n, Right set) loop !n currentSize acc (f : files) = do size <- fromIntegral <$> getFileSize f - if size > mergeFileSize -- just copy huge files + if size > mergeFileSize && fileFormat == BinaryFormat + -- just copy huge binary files then do write (n, Left f) loop (n+1) currentSize acc files