Skip to content

Commit 49cd62c

Browse files
committed
Prevent cleaning tmcproject.yml
1 parent d153281 commit 49cd62c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

crates/tmc-langs-framework/src/plugin.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ pub trait LanguagePlugin {
124124
let policy = Self::StudentFilePolicy::new(target_location)?;
125125

126126
// used to clean non-student files not in the zip later
127-
let mut files_from_zip = HashSet::new();
127+
let mut files_from_archive = HashSet::new();
128+
files_from_archive.insert(target_location.join(".tmcproject.yml")); // prevent cleaning .tmcproject.yml
128129

129130
let mut iter = archive.iter()?;
130131
loop {
@@ -145,7 +146,7 @@ pub trait LanguagePlugin {
145146
let path_in_target = target_location.join(relative);
146147
log::trace!("processing {:?} -> {:?}", file_path, path_in_target);
147148

148-
files_from_zip.insert(path_in_target.clone());
149+
files_from_archive.insert(path_in_target.clone());
149150

150151
if !path_in_target.exists() {
151152
// just extract
@@ -175,8 +176,8 @@ pub trait LanguagePlugin {
175176
}
176177

177178
if clean {
178-
// delete non-student files that were not in zip
179-
log::debug!("deleting non-student files not in zip");
179+
// delete non-student files that were not in archive
180+
log::debug!("deleting non-student files not in archive");
180181
for entry in WalkDir::new(target_location)
181182
.into_iter()
182183
.filter_map(|e| e.ok())
@@ -185,7 +186,7 @@ pub trait LanguagePlugin {
185186
.path()
186187
.strip_prefix(target_location)
187188
.expect("all entries are inside target");
188-
if !files_from_zip.contains(entry.path())
189+
if !files_from_archive.contains(entry.path())
189190
&& (policy.is_updating_forced(entry.path())?
190191
|| !policy.is_student_file(relative))
191192
{

0 commit comments

Comments
 (0)