Skip to content

Commit 1631a89

Browse files
committed
feat: remove unused sprite validation + warning
2 parents 3db4484 + ef0fe33 commit 1631a89

File tree

1 file changed

+2
-71
lines changed
  • martin-core/src/resources/sprites

1 file changed

+2
-71
lines changed

martin-core/src/resources/sprites/mod.rs

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ impl SpriteSources {
7676
let disp_path = path.display();
7777

7878
if path.is_file() {
79-
warn!("Ignoring non-directory sprite source {id} from {disp_path}");
8079
return Err(SpriteError::DirectoryValidationFailed(
8180
path,
8281
"Path is not a directory".to_string(),
8382
));
8483
}
8584

8685
if !path.exists() {
87-
warn!("Sprite source {id} path doesn't exist: {disp_path}");
8886
return Err(SpriteError::DirectoryValidationFailed(
8987
path,
9088
"Path does not exist".to_string(),
@@ -121,7 +119,6 @@ impl SpriteSources {
121119
let metadata = tokio::fs::metadata(path).await.map_err(on_err)?;
122120

123121
if !metadata.is_dir() {
124-
warn!("Sprite source is not a directory: {disp_path}");
125122
return Err(SpriteError::DirectoryValidationFailed(
126123
path.clone(),
127124
"Path is not a directory".to_string(),
@@ -138,32 +135,21 @@ impl SpriteSources {
138135
if let Some(extension) = entry_path.extension() {
139136
if extension.to_string_lossy().to_lowercase() == "svg" {
140137
if let Err(e) = self.validate_svg_file(&entry_path).await {
141-
warn!("Invalid SVG file {}: {}", entry_path.display(), e);
138+
return Err(e);
142139
}
143140
}
144141
}
145142
}
146143
}
147144

148145
if total_files == 0 {
149-
warn!("Empty sprite directory: {disp_path}");
150146
return Err(SpriteError::EmptyDirectory(path.clone()));
151147
}
152148

153149
if svg_count == 0 && sprite_output_files.is_empty() {
154-
warn!(
155-
"No SVG source files found in sprite directory: {disp_path}. \
156-
Found pre-generated sprite files: {}. \
157-
Martin requires source SVG files, not pre-generated sprite outputs.",
158-
sprite_output_files.join(", ")
159-
);
160150
return Err(SpriteError::DirectoryValidationFailed(
161151
path.clone(),
162-
format!(
163-
"Directory contains pre-generated sprite files ({}) but no source SVG files. \
164-
Please provide a directory with .svg files instead.",
165-
sprite_output_files.join(", ")
166-
),
152+
"Directory contains no SVG files".to_string(),
167153
));
168154
}
169155

@@ -205,56 +191,6 @@ impl SpriteSources {
205191
Ok(())
206192
}
207193

208-
/// Validates all configured sprite sources and logs a summary.
209-
pub async fn validate_all_sources(&self) -> Result<(), SpriteError> {
210-
if self.0.is_empty() {
211-
info!("No sprite sources configured");
212-
return Ok(());
213-
}
214-
215-
let mut total_sources = 0;
216-
let mut valid_sources = 0;
217-
let mut total_svg_files = 0;
218-
let mut validation_errors = Vec::new();
219-
220-
info!("Validating {} configured sprite sources...", self.0.len());
221-
222-
for source in &self.0 {
223-
total_sources += 1;
224-
let id = source.key();
225-
let path = &source.value().path;
226-
227-
match self.validate_source_directory(path).await {
228-
Ok(()) => {
229-
valid_sources += 1;
230-
if let Ok(svg_count) = Self::count_svg_files(path).await {
231-
total_svg_files += svg_count;
232-
}
233-
}
234-
Err(e) => {
235-
warn!("Validation failed for sprite source {id}: {e}");
236-
validation_errors.push((id.clone(), e));
237-
}
238-
}
239-
}
240-
241-
if validation_errors.is_empty() {
242-
info!(
243-
"Sprite source validation completed successfully: {valid_sources}/{total_sources} sources valid, {total_svg_files} total SVG files",
244-
);
245-
} else {
246-
warn!(
247-
"Sprite source validation completed with errors: {valid_sources}/{total_sources} sources valid, {} errors encountered",
248-
validation_errors.len()
249-
);
250-
for (id, error) in &validation_errors {
251-
warn!(" - {id}: {error}");
252-
}
253-
}
254-
255-
Ok(())
256-
}
257-
258194
/// Scans a directory and returns file counts.
259195
async fn scan_directory_files(
260196
path: &PathBuf,
@@ -293,11 +229,6 @@ impl SpriteSources {
293229

294230
Ok((total_files, svg_count, sprite_output_files))
295231
}
296-
297-
async fn count_svg_files(path: &PathBuf) -> Result<usize, SpriteError> {
298-
let (_, svg_count, _) = Self::scan_directory_files(path).await?;
299-
Ok(svg_count)
300-
}
301232
}
302233

303234
impl SpriteSources {

0 commit comments

Comments
 (0)