mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Refine adjacent meta file removal logic in ApiService
- Updated the logic for removing adjacent meta files to correctly derive base names by stripping known script suffixes, improving accuracy in file handling. - Enhanced comments for clarity on the naming resolution process, ensuring better understanding of the changes made to file paths during sync operations.
This commit is contained in:
parent
6ce3717663
commit
033d8c6892
1 changed files with 13 additions and 4 deletions
|
|
@ -347,15 +347,24 @@ impl ApiService {
|
|||
} else {
|
||||
log::info!("Syncback: Removed file at {}", path.display());
|
||||
}
|
||||
// Also remove adjacent meta file
|
||||
if let Some(instance_name) = path
|
||||
// Also remove adjacent meta file.
|
||||
// Strip known script suffixes (.server, .client, etc.)
|
||||
// rather than splitting on dots, so that names containing
|
||||
// dots (e.g. "Config.Client.server.luau") resolve correctly.
|
||||
if let Some(file_stem) = path
|
||||
.file_stem()
|
||||
.and_then(|s| s.to_str())
|
||||
.map(|s| s.split('.').next().unwrap_or(s).to_string())
|
||||
{
|
||||
let base_name = file_stem
|
||||
.strip_suffix(".server")
|
||||
.or_else(|| file_stem.strip_suffix(".client"))
|
||||
.or_else(|| file_stem.strip_suffix(".plugin"))
|
||||
.or_else(|| file_stem.strip_suffix(".local"))
|
||||
.or_else(|| file_stem.strip_suffix(".legacy"))
|
||||
.unwrap_or(file_stem);
|
||||
if let Some(parent_dir) = path.parent() {
|
||||
let meta_path =
|
||||
parent_dir.join(format!("{}.meta.json5", instance_name));
|
||||
parent_dir.join(format!("{}.meta.json5", base_name));
|
||||
if meta_path.exists() {
|
||||
self.suppress_path(&meta_path);
|
||||
let _ = fs::remove_file(&meta_path);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue