Repository navigation
refactor: refactor admin config to global #1818
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -1242,18 +1242,13 @@ impl MonoApiService { | |||||||
| .map_err(|e| GitError::CustomError(format!("Failed to update CL status: {}", e)))?; | ||||||||
|
|
||||||||
| // Invalidate admin cache when .mega_cedar.json is modified. | ||||||||
| // File paths from get_sorted_changed_file_list are relative to cl.path. | ||||||||
| if let Ok(files) = self.get_sorted_changed_file_list(&cl.link, None).await { | ||||||||
| for file in &files { | ||||||||
| let normalized_path = file.replace('\\', "/"); | ||||||||
| if normalized_path.ends_with(crate::api_service::admin_ops::ADMIN_FILE) { | ||||||||
| let root_dir = if cl.path == "/" { | ||||||||
| crate::api_service::admin_ops::extract_root_dir(&normalized_path) | ||||||||
| } else { | ||||||||
| crate::api_service::admin_ops::extract_root_dir(&cl.path) | ||||||||
| }; | ||||||||
| self.invalidate_admin_cache(&root_dir).await; | ||||||||
| } | ||||||||
| let admin_file_modified = files.iter().any(|file| { | ||||||||
| let normalized = file.replace('\\', "/"); | ||||||||
| normalized.ends_with(crate::api_service::admin_ops::ADMIN_FILE) | ||||||||
|
||||||||
| normalized.ends_with(crate::api_service::admin_ops::ADMIN_FILE) | |
| let admin_file_path = crate::api_service::admin_ops::ADMIN_FILE; | |
| normalized == admin_file_path || normalized == format!("/{}", admin_file_path) |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -417,26 +417,37 @@ pub fn init_trees( | |||||||||||||
| let mut root_items = Vec::new(); | ||||||||||||||
| let mut trees = Vec::new(); | ||||||||||||||
| let mut blobs = Vec::new(); | ||||||||||||||
|
|
||||||||||||||
| // Create unique .gitkeep for each root directory to ensure different tree hashes | ||||||||||||||
|
||||||||||||||
| // Create unique .gitkeep for each root directory to ensure different tree hashes | |
| // Create a .gitkeep for each root directory with directory-specific content. | |
| // This ensures that each root gets a distinct blob ID and thus a distinct tree hash. | |
| // If all .gitkeep files had identical content, their blobs (and the trees containing | |
| // them) would be identical, which could cause different roots to share the same | |
| // tree hash and lead to confusing or incorrect behavior when working with Git trees. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lookup now only searches the root tree for
/.mega_cedar.json, so repositories created before this change (which only wrote.mega_cedar.jsoninto each root directory) will fail admin checks with a “not found in root directory” error until a migration adds the new root file. That means/api/v1/admin/meand/api/v1/admin/listwill start returning 500s after upgrade for existing repos. Consider a backward-compatible fallback (e.g., probe legacy locations when root lookup fails) or ensure a migration creates the root file before enabling this code path.Useful? React with 👍 / 👎.