@@ -274,6 +274,8 @@ ClassMethod Compact(Path As %String = "", gzip As %Boolean = 1, pFileName As %St
274274 if relativeTo =" " {
275275 set relativeTo = ##class (%File ).ParentDirectoryName (Path )
276276 }
277+ set relativeTo = ##class (%File ).NormalizeDirectory (relativeTo )
278+
277279 Do ..ConstructTar (Path , relativeTo , archive )
278280 Set tSC = archive .%Save ()
279281 $$$ThrowOnError(tSC )
@@ -284,6 +286,7 @@ ClassMethod Compact(Path As %String = "", gzip As %Boolean = 1, pFileName As %St
284286
285287ClassMethod ConstructTar (Path As %String , RelativeTo As %String , archive As %Stream .GlobalBinary )
286288{
289+ QUIT :Path =archive .Filename // skip archive itself
287290 set blockSize = ..#BLOCKSIZE
288291 if ##class (%File ).DirectoryExists (Path ) {
289292 set Path = ##class (%File ).NormalizeDirectory (Path )
@@ -320,14 +323,16 @@ ClassMethod ConstructTar(Path As %String, RelativeTo As %String, archive As %Str
320323 set header = obj .ConstructHeader ()
321324 }
322325
323- if (flag = 0 ) {
326+ if (size > 0 ) {
324327 do archive .Write (header )
325328 set fs = ##class (%Stream.FileBinary ).%New ()
326329 set fs .Filename = Path
327330 do archive .CopyFrom (fs )
328- set paddingSize = blockSize - (size # blockSize )
329- set padding = $TRANSLATE ($JUSTIFY (" " , paddingSize ), " " , $CHAR (0 ))
330- do archive .Write (padding )
331+ if (size # blockSize ) > 0 {
332+ set paddingSize = blockSize - (size # blockSize )
333+ set padding = $TRANSLATE ($JUSTIFY (" " , paddingSize ), " " , $CHAR (0 ))
334+ do archive .Write (padding )
335+ }
331336 } else {
332337 do archive .Write (header )
333338 set rs = ##class (%File ).FileSetFunc (Path , , " Type" , 1 )
0 commit comments