Skip to content

Commit c0a8a9b

Browse files
committed
Fixed an error in copying files in prepare submission and a fd deadlock
1 parent c86f500 commit c0a8a9b

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

tmc-langs/src/config/tmc_config.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ impl TmcConfig {
9696
match toml::from_slice(&buf) {
9797
// successfully read file, try to deserialize
9898
Ok(config) => config, // successfully read and deserialized the config
99-
Err(_) => {
99+
Err(e) => {
100100
log::error!(
101-
"Failed to deserialize config at {}, resetting",
101+
"Failed to deserialize config at {} due to {e}, resetting",
102102
path.display()
103103
);
104+
drop(guard);
105+
drop(lock);
104106
Self::init_at(client_name, &path)?
105107
}
106108
}

tmc-langs/src/submission_packaging.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,22 @@ pub fn prepare_submission(
214214
let config = plugin.get_exercise_packaging_configuration(config)?;
215215
for path in config.student_file_paths {
216216
let student_file = project_root.join(&path);
217-
if student_file.exists() {
217+
if student_file.is_file() {
218218
file_util::copy(student_file, &dest)?;
219+
} else if student_file.is_dir() {
220+
let mut dest = dest.join(path);
221+
dest.pop(); // the dest will include the target dir, pop to avoid copying a/b/c to a/b/c/c
222+
file_util::copy(&student_file, dest)?;
219223
}
220224
}
221225
for path in config.exercise_file_paths {
222226
let exercise_file = tests_dir.join(&path);
223-
if exercise_file.exists() {
224-
// todo --no-target-directory?
227+
// todo --no-target-directory?
228+
if exercise_file.is_file() {
229+
file_util::copy(exercise_file, &dest)?;
230+
} else if exercise_file.is_dir() {
231+
let mut dest = dest.join(path);
232+
dest.pop(); // the dest will include the target dir, pop to avoid copying a/b/c to a/b/c/c
225233
file_util::copy(exercise_file, &dest)?;
226234
}
227235
}

0 commit comments

Comments
 (0)