-
Notifications
You must be signed in to change notification settings - Fork 74
[scorpio]: Fix bug in overlayfs & init LFS code #871
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -3,4 +3,8 @@ workspace = "/home/luxian/megadir/mount" | |
store_path = "/home/luxian/megadir/store" | ||
git_author = "MEGA" | ||
git_email = "[email protected]" | ||
works = [] | ||
|
||
[[works]] | ||
path = "third-part/buck-hello" | ||
node = 8 | ||
hash = "5f70f0f460d92d73eac0ea09ef2edb3840bfc68f" |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
output.txt |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
# Scorpio Log Analysis Tool, used for extracting abnormal requests (function not returning) | ||
import re | ||
from collections import defaultdict | ||
|
||
def extract_unique_id_lines(input_path, output_path): | ||
"""Extract lines with unique IDs and save them to a file""" | ||
|
||
# Compile optimized regular expression (note the comments in re.VERBOSE mode) | ||
uuid_regex = re.compile( | ||
r'''^ID: # Fixed starting identifier | ||
\{? # Optional left curly brace | ||
( # Start capturing group | ||
[0-9a-fA-F]{8} # 8 hexadecimal digits | ||
- # Separator | ||
(?:[0-9a-fA-F]{4}-){3} # Three middle groups (non-capturing group for performance) | ||
[0-9a-fA-F]{12} # Last 12 digits | ||
) # End capturing group | ||
\}? # Optional right curly brace | ||
(?!\S) # Ensure ID is followed by a space or end of line | ||
''', | ||
re.IGNORECASE | re.VERBOSE | ||
) | ||
uuid_regex = re.compile( | ||
r'^ID:\{?([0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})\}?\b', | ||
re.IGNORECASE | ||
) | ||
|
||
id_counter = defaultdict(int) | ||
logs = defaultdict(int) | ||
# First pass: Count occurrences of each ID | ||
with open(input_path, 'r', encoding='utf-8') as f: | ||
for line_num, line in enumerate(f, 1): | ||
# Clean up line content (ignore comments and whitespace) | ||
line = line.split('#')[0].strip() | ||
if match := uuid_regex.search(line): | ||
# Extract the standardized ID (convert to lowercase + remove braces) | ||
raw_uuid = match.group(1).strip('{}') | ||
standard_uuid = raw_uuid.lower() | ||
logs[standard_uuid] = line | ||
id_counter[standard_uuid] += 1 | ||
|
||
# Second pass: Record line numbers for unique IDs | ||
unique_lines = [] | ||
with open(input_path, 'r', encoding='utf-8') as f: | ||
for line_num, line in enumerate(f, 1): | ||
line = line.split('#')[0].strip() | ||
if match := uuid_regex.search(line): | ||
raw_uuid = match.group(1).strip('{}') | ||
standard_uuid = raw_uuid.lower() | ||
if id_counter[standard_uuid] == 1: | ||
unique_lines.append(logs[standard_uuid]) | ||
|
||
# Write the results to a file (one line number per line) | ||
with open(output_path, 'w', encoding='utf-8') as f: | ||
f.write('\n'.join(map(str, unique_lines))) | ||
|
||
|
||
# For example, run this script with: python log_analysis.py input.log output.txt | ||
if __name__ == "__main__": | ||
import sys | ||
if len(sys.argv) != 2: | ||
print(f"Usage: {sys.argv[0]} input.log") | ||
sys.exit(1) | ||
|
||
extract_unique_id_lines(sys.argv[1], "output.txt") | ||
print(f"Unique ID line numbers have been saved") |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,163 @@ | ||
use axum::{ | ||
routing::{get, post, delete}, | ||
Router, | ||
extract::{Query, Path}, | ||
Json, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::collections::HashMap; | ||
|
||
pub fn create_app() -> Router { | ||
Router::new() | ||
.nest("/lfs", Router::new() | ||
// Track LFS paths (equivalent to the track command) | ||
.route("/attributes/track", post(track_lfs_path)) | ||
// Untrack paths (equivalent to the untrack command) | ||
.route("/attributes/untrack", post(untrack_lfs_path)) | ||
// List locked files in the current branch (equivalent to lfs locks) | ||
.route("/locks", get(list_locks)) | ||
// Lock a file (equivalent to lfs lock) | ||
.route("/locks/:path", post(create_lock)) | ||
// Unlock a file (equivalent to lfs unlock) | ||
.route("/locks/:path", delete(remove_lock)) | ||
// Display LFS file information (equivalent to lfs ls - files) | ||
.route("/objects/metadata", get(list_lfs_files)) | ||
) | ||
} | ||
|
||
// Region 1: Attribute management endpoints =============================================== | ||
|
||
#[derive(Debug, Deserialize)] | ||
struct TrackPathsRequest { | ||
patterns: Vec<String>, | ||
} | ||
|
||
async fn track_lfs_path( | ||
Json(payload): Json<TrackPathsRequest> | ||
) -> Result<Json<HashMap<String, String>>, AppError> { | ||
// Business logic: | ||
// 1. Update the.gitattributes file | ||
// 2. Return something like {"status": "tracked", "added_paths": [...]} | ||
Ok(Json(HashMap::from([ | ||
("status".to_string(), "success".to_string()), | ||
("added_paths".to_string(), payload.patterns.join(",")) | ||
]))) | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
struct UntrackPathsRequest { | ||
paths: Vec<String>, | ||
} | ||
|
||
async fn untrack_lfs_path( | ||
Json(payload): Json<UntrackPathsRequest> | ||
) -> Result<Json<HashMap<String, String>>, AppError> { | ||
// Business logic: Remove paths from.gitattributes | ||
Ok(Json(HashMap::from([ | ||
("status".to_string(), "success".to_string()), | ||
("removed_paths".to_string(), payload.paths.join(",")) | ||
]))) | ||
} | ||
|
||
// Region 2: File lock management endpoints ============================================ | ||
|
||
#[derive(Debug, Deserialize)] | ||
struct ListLocksQuery { // Corresponds to the three option parameters of the CLI | ||
id: Option<String>, | ||
path: Option<String>, | ||
limit: Option<u64>, | ||
} | ||
|
||
#[derive(Debug, Serialize)] | ||
struct LockInfo { | ||
id: String, | ||
path: String, | ||
owner: String, | ||
locked_at: i64, // Timestamp | ||
} | ||
|
||
async fn list_locks( | ||
Query(params): Query<ListLocksQuery> | ||
) -> Result<Json<Vec<LockInfo>>, AppError> { | ||
// Business logic: Query the list of locks in the current branch | ||
let mock_data = vec![LockInfo { | ||
id: "123".to_string(), | ||
path: params.path.unwrap_or_default(), | ||
owner: "user1".to_string(), | ||
locked_at: 1672531200 | ||
}]; | ||
Ok(Json(mock_data)) | ||
} | ||
|
||
async fn create_lock( | ||
Path(path): Path<String> // Get the file path from the URL path | ||
) -> Result<Json<LockInfo>, AppError> { | ||
// Business logic: Create a new lock | ||
Ok(Json(LockInfo { | ||
id: "456".to_string(), | ||
path, | ||
owner: "current_user".to_string(), | ||
locked_at: 1672531200 | ||
})) | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
struct UnlockParams { // CLI unlock parameters | ||
force: bool, | ||
id: Option<String>, | ||
} | ||
|
||
async fn remove_lock( | ||
Path(path): Path<String>, | ||
Query(params): Query<UnlockParams> | ||
) -> Result<Json<HashMap<String, String>>, AppError> { | ||
// Business logic: Force or normal unlock | ||
Ok(Json(HashMap::from([ | ||
("status".to_string(), "unlocked".to_string()), | ||
("path".to_string(), path), | ||
("force_mode".to_string(), params.force.to_string()) | ||
]))) | ||
} | ||
|
||
// Region 3: LFS file information viewing endpoints ======================================= | ||
|
||
#[derive(Debug, Deserialize)] | ||
struct MetadataQueryParams { // Corresponds to the CLI option parameters | ||
long: Option<bool>, | ||
size: Option<bool>, | ||
name_only: Option<bool> | ||
} | ||
|
||
#[derive(Debug, Serialize)] | ||
struct LFSFileMeta { | ||
oid: String, | ||
symbolic_type: String, // "*" or "-" | ||
path: String, | ||
size_human: Option<String> // Nullable field | ||
} | ||
|
||
async fn list_lfs_files( | ||
Query(params): Query<MetadataQueryParams> | ||
) -> Result<Json<Vec<LFSFileMeta>>, AppError> { | ||
// Business logic: Get the list of LFS files in the current branch | ||
let mock_file = LFSFileMeta { | ||
oid: "01ba4719...".to_string(), | ||
symbolic_type: "*".to_string(), | ||
path: "assets/image.png".to_string(), | ||
size_human: params.size.then(|| "15.2 MB".to_string()) | ||
}; | ||
Ok(Json(vec![mock_file])) | ||
} | ||
|
||
// Error handling infrastructure | ||
#[derive(Debug)] | ||
struct AppError(anyhow::Error); | ||
|
||
impl IntoResponse for AppError { | ||
fn into_response(self) -> axum::response::Response { | ||
( | ||
StatusCode::INTERNAL_SERVER_ERROR, | ||
Json(HashMap::from([("error", self.0.to_string())])) | ||
).into_response() | ||
} | ||
} |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.