forked from runtipi/runtipi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(archive-manager): switch to plain tar usage
- Loading branch information
1 parent
fa754bb
commit 0f15c4e
Showing
2 changed files
with
11 additions
and
11 deletions.
There are no files selected for viewing
12 changes: 3 additions & 9 deletions
12
packages/shared/src/node/modules/archive/archive-manager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
import fs from 'node:fs'; | ||
import gunzip from 'gunzip-maybe'; | ||
import { extract, pack } from 'tar-fs'; | ||
import { execAsync } from 'src/node/helpers/exec-async'; | ||
|
||
export class ArchiveManager { | ||
createTarGz = async (sourceDir: string, destinationFile: string) => { | ||
return new Promise<void>((resolve, reject) => { | ||
pack(sourceDir).pipe(gunzip()).pipe(fs.createWriteStream(destinationFile)).on('finish', resolve).on('error', reject); | ||
}); | ||
return execAsync(`tar -czf ${destinationFile} -C ${sourceDir} .`); | ||
}; | ||
|
||
extractTarGz = async (sourceFile: string, destinationDir: string) => { | ||
return new Promise<void>((resolve, reject) => { | ||
fs.createReadStream(sourceFile).pipe(gunzip()).pipe(extract(destinationDir)).on('finish', resolve).on('error', reject); | ||
}); | ||
return execAsync(`tar -xzf ${sourceFile} -C ${destinationDir}`); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters