Decompress
Decompresses a single compressed file to the target path. Automatically detects whether the file is a tar-wrapped archive or pure compression format.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
-
Source Path - Path to the compressed file to decompress. Supports various compression formats.
-
Target Path - Destination path for the decompressed file or directory. The content will be extracted to this location.
How It Works
The Decompress node intelligently handles different types of compressed files:
- Detects the compression format from the file extension
- Analyzes the file content to determine if it's tar-wrapped (created by Compress node) or pure compression (created by external tools)
- For tar-wrapped files: Extracts the tar archive and decompresses in one step, preserving the original filename and directory structure
- For pure compression: Decompresses the file directly
- Saves the decompressed content to the target path
Smart Detection
The node performs magic byte checking to determine the file type:
- Checks for tar header signature ("ustar" at byte offset 257)
- Handles files created by the Compress node (tar-wrapped)
- Handles files created by external compression tools (pure compression)
Supported Compression Formats
Compression Formats with Tar Detection
- .gz, .gzip - Gzip compressed files
- .bz2, .bzip2 - Bzip2 compressed files
- .zst, .zstd - Zstandard compressed files
- .xz - XZ compressed files
- .lz4 - LZ4 compressed files
- .br - Brotli compressed files
Other Formats
- .zip - Zip archives
- Any other format supported by the archiver library
Examples
Example 1: Decompress a Gzip File
Decompress a Gzip compressed file:
// Set source and target paths
msg.compressedFile = "/home/user/archives/application.log.gz";
msg.outputPath = "/home/user/logs/";
Configure the Decompress node:
- Source Path:
{{msg.compressedFile}} - Target Path:
{{msg.outputPath}}
Example 2: Decompress a Zstandard Archive
Decompress a folder that was compressed with Zstandard:
// Decompress a Zstandard archive
msg.zstFile = "/home/user/backups/project.zst";
msg.extractPath = "/home/user/restore/";
Configure the Decompress node:
- Source Path:
{{msg.zstFile}} - Target Path:
{{msg.extractPath}}
Example 3: Decompress XZ Compressed File
Decompress a file with maximum compression (XZ):
// Decompress XZ compressed file
msg.xzFile = "/home/user/archives/database.sql.xz";
msg.outputPath = "/home/user/restore/";
Configure the Decompress node:
- Source Path:
{{msg.xzFile}} - Target Path:
{{msg.outputPath}}
Example 4: Batch Decompression
Decompress multiple files in a loop:
// Define array of compressed files
msg.compressedFiles = [
"/home/user/archives/file1.gz",
"/home/user/archives/file2.zst",
"/home/user/archives/file3.xz"
];
// Set output directory
msg.outputDir = "/home/user/extracted/";
// Set current index
msg.currentIndex = 0;
Configure the Decompress node:
- Source Path:
{{msg.compressedFiles[msg.currentIndex]}} - Target Path:
{{msg.outputDir}}
Use a Loop or Iterator to process all files.
Example 5: Conditional Decompression
Check file size before decompressing:
const fs = require('fs');
const path = require('path');
msg.compressedFile = "/home/user/archives/large-file.gz";
// Get file size
const stats = fs.statSync(msg.compressedFile);
const fileSizeInMB = stats.size / (1024 * 1024);
// Set output path
msg.outputPath = "/home/user/temp/";
// Store file info for logging
msg.fileInfo = {
name: path.basename(msg.compressedFile),
sizeInMB: fileSizeInMB.toFixed(2),
format: path.extname(msg.compressedFile)
};
Configure the Decompress node:
- Source Path:
{{msg.compressedFile}} - Target Path:
{{msg.outputPath}}
Example 6: Decompress with Error Handling
Decompress with proper error handling in workflow:
// Set paths
msg.archiveFile = "/home/user/downloads/data.gz";
msg.extractPath = "/home/user/data/extracted/";
// Initialize error tracking
msg.decompressErrors = [];
msg.decompressSuccess = false;
Configure the Decompress node:
- Source Path:
{{msg.archiveFile}} - Target Path:
{{msg.extractPath}} - Continue On Error: Enabled
Add a Function node after Decompress to check results:
// Check if decompression was successful
const fs = require('fs');
if (fs.existsSync(msg.extractPath)) {
msg.decompressSuccess = true;
msg.message = "Decompression completed successfully";
} else {
msg.decompressSuccess = false;
msg.message = "Decompression failed";
}
Usage Tips
-
Target Path Considerations:
- For tar-wrapped files (created by Compress node), files are extracted to the target directory
- For pure compressed single files, specify the complete output file path
- Create the target directory beforehand if it doesn't exist
-
Format Compatibility:
- The node automatically handles files created by both Robomotion's Compress node and external tools
- No need to specify the compression format - it's detected automatically
-
Performance:
- Decompression speed varies by format:
- LZ4: Fastest decompression
- Gzip/Zstandard: Fast decompression
- Bzip2/XZ: Slower decompression
- Large files may take significant time, especially with XZ compression
- Decompression speed varies by format:
-
Disk Space:
- Ensure sufficient disk space for the decompressed content
- Compressed files can expand significantly (5-10x or more)
- Monitor available disk space before decompressing large files
-
File Integrity:
- Corrupted compressed files will cause decompression to fail
- Always verify compressed files before decompressing if downloaded from external sources
Common Errors and Solutions
Error: "Source path cannot be empty"
Cause: The Source Path input is not provided or is empty.
Solution: Ensure you provide a valid path to the compressed file.
Error: "Source path does not exist"
Cause: The specified compressed file does not exist at the given path.
Solution:
- Verify the source path is correct
- Check that the file exists and hasn't been moved or deleted
- Ensure proper path formatting
Error: "Target path cannot be empty"
Cause: The Target Path input is not provided or is empty.
Solution: Provide a valid destination path for the decompressed content.
Error: Invalid or corrupted archive
Cause: The compressed file is corrupted or in an invalid format.
Solution:
- Verify the file was downloaded or created completely
- Check the file isn't corrupted (re-download if necessary)
- Ensure the file extension matches the actual compression format
- Try opening the file with a standard decompression tool to verify integrity
Error: Unsupported compression format
Cause: The file format is not recognized or supported.
Solution:
- Check that the file extension is one of the supported formats
- Verify the file is actually compressed (not just renamed)
- Use the appropriate node for the file type (e.g., Unarchive for multi-file archives)
Error: Permission denied
Cause: Insufficient permissions to read the source file or write to the target location.
Solution:
- Ensure read permissions for the compressed file
- Verify write permissions for the target directory
- Check file ownership and permissions
Error: Disk space insufficient
Cause: Not enough disk space to extract the decompressed content.
Solution:
- Free up disk space on the target drive
- Choose a different target location with more available space
- Check the expected decompressed size before proceeding
Error: Target file already exists
Cause: A file already exists at the target path.
Solution:
- Remove or rename the existing file
- Choose a different target path
- Implement file cleanup in your workflow before decompression
Related Nodes
-
- Compress files and folders
- Unarchive - Extract all files from multi-file archives
- Extract File - Extract a specific file from an archive
- Archive - Create archives with multiple files