Warn the user on duplicate folder names

See #31
This commit is contained in:
FliegendeWurst 2022-04-26 21:44:25 +02:00
parent 1953a019aa
commit 147af49eb8
2 changed files with 13 additions and 4 deletions

View File

@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Added
- Display a warning if two or more courses/folders have the same name ([#31])
## [0.3.3] - 2022-03-21
### Addded
@ -153,6 +155,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.1.0] - 2020-04-21
(undocumented)
[#31]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/issues/31
[#30]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/issues/30
[#28]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/pull/28
[#27]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/issues/27

View File

@ -1,4 +1,4 @@
use std::{path::Path, sync::Arc};
use std::{path::Path, sync::Arc, collections::HashSet};
use anyhow::{Context, Result};
@ -20,11 +20,17 @@ pub async fn download(path: &Path, ilias: Arc<ILIAS>, url: &URL) -> Result<()> {
.context("failed to write folder page html")?;
}
}
let mut names = HashSet::new();
for item in content.0 {
let item = item?;
let path = path.join(file_escape(
let item_name = file_escape(
ilias.course_names.get(item.name()).map(|x| &**x).unwrap_or(item.name()),
));
);
if names.contains(&item_name) {
warning!(format => "folder {} contains duplicated folder {:?}", path.display(), item_name);
}
names.insert(item_name.clone());
let path = path.join(item_name);
let ilias = Arc::clone(&ilias);
spawn(process_gracefully(ilias, path, item));
}