Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the sync crate repository path error #579

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions atlas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## Atlas Module
34 changes: 23 additions & 11 deletions scripts/crates-sync/crates-sync.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os # For file and directory operations
import sys # For system-specific parameters and functions
import json # For JSON parsing
import urllib.request # For downloading files from URLs
import tarfile # For handling tar archives
import subprocess # For running system commands
import shutil # For high-level file operations
from collections import defaultdict # For creating dictionaries with default values
from packaging import version # For parsing and comparing version numbers
import os
import sys
import json
import urllib.request
import tarfile
import subprocess
import shutil
from collections import defaultdict
from packaging import version

def ensure_directory(path):
# Create a directory if it doesn't exist
Expand Down Expand Up @@ -77,8 +77,20 @@ def filter_member(tarinfo, filterpath):
print(f"Warning: Empty crate file {crate_path}. Skipping extraction.")
return False

# Extract directly to the target directory
safe_extract(tar, extract_path)
# Create a temporary directory for extraction
temp_extract_path = extract_path + "_temp"
ensure_directory(temp_extract_path)

# Extract to the temporary directory
safe_extract(tar, temp_extract_path)

# Move contents from the nested directory to the target directory
nested_dir = os.path.join(temp_extract_path, os.listdir(temp_extract_path)[0])
for item in os.listdir(nested_dir):
shutil.move(os.path.join(nested_dir, item), extract_path)

# Remove the temporary directory
shutil.rmtree(temp_extract_path)

print(f"Extracted version to {extract_path}")
return True
Expand Down
Loading