File tree 6 files changed +42
-20
lines changed
tmc-langs-util/src/file_util
6 files changed +42
-20
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ authors = [
22
22
edition = " 2021"
23
23
license = " MIT OR Apache-2.0"
24
24
rust-version = " 1.70.0"
25
- version = " 0.36.4 "
25
+ version = " 0.37.0 "
26
26
27
27
[workspace .dependencies ]
28
28
mooc-langs-api = { git = " https://github.com/rage/secret-project-331.git" , rev = " 9fb5f894c72932e77dafa6d0f00df7a8abdfa84c" }
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ impl CSharpPlugin {
132
132
}
133
133
134
134
/// Project directory:
135
- /// Contains a src directory which contains a .csproj file (which may be inside a subdirectory).
135
+ /// Contains a src directory which contains a .cs or . csproj file (which may be inside a subdirectory).
136
136
impl LanguagePlugin for CSharpPlugin {
137
137
const PLUGIN_NAME : & ' static str = "csharp" ;
138
138
const DEFAULT_SANDBOX_IMAGE : & ' static str = "eu.gcr.io/moocfi-public/tmc-sandbox-csharp:latest" ;
@@ -145,7 +145,10 @@ impl LanguagePlugin for CSharpPlugin {
145
145
. max_depth ( 2 )
146
146
. into_iter ( )
147
147
. filter_map ( |e| e. ok ( ) )
148
- . any ( |e| e. path ( ) . extension ( ) == Some ( & OsString :: from ( "csproj" ) ) )
148
+ . any ( |e| {
149
+ let ext = e. path ( ) . extension ( ) ;
150
+ ext == Some ( & OsString :: from ( "cs" ) ) || ext == Some ( & OsString :: from ( "csproj" ) )
151
+ } )
149
152
}
150
153
151
154
fn find_project_dir_in_archive < R : Read + Seek > (
@@ -155,9 +158,10 @@ impl LanguagePlugin for CSharpPlugin {
155
158
let project_dir = loop {
156
159
let next = iter. with_next ( |entry| {
157
160
let file_path = entry. path ( ) ?;
161
+ let ext = file_path. extension ( ) ;
158
162
159
163
if entry. is_file ( )
160
- && file_path . extension ( ) == Some ( OsStr :: new ( "csproj" ) )
164
+ && ( ext == Some ( OsStr :: new ( "cs" ) ) || ext == Some ( OsStr :: new ( "csproj" ) ) )
161
165
&& !file_path. components ( ) . any ( |c| c. as_os_str ( ) == "__MACOSX" )
162
166
{
163
167
if let Some ( parent) = file_path. parent ( ) {
Original file line number Diff line number Diff line change @@ -621,7 +621,7 @@ fn run_tmc_inner(
621
621
output_path,
622
622
} => {
623
623
let mut output_lock = Lock :: dir ( & output_path, file_util:: LockOptions :: Write ) ?;
624
- let _output_guard = output_lock. lock ( ) ?;
624
+ let output_guard = output_lock. lock ( ) ?;
625
625
626
626
tmc_langs:: download_old_submission (
627
627
client,
@@ -630,6 +630,8 @@ fn run_tmc_inner(
630
630
submission_id,
631
631
save_old_state,
632
632
) ?;
633
+ drop ( output_guard) ;
634
+ output_lock. forget ( ) ;
633
635
CliOutput :: finished ( "extracted project" )
634
636
}
635
637
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ pub struct Lock {
17
17
pub path : PathBuf ,
18
18
options : LockOptions ,
19
19
lock_file_path : Option < PathBuf > ,
20
+ forget : bool ,
20
21
}
21
22
22
23
impl Lock {
@@ -32,6 +33,7 @@ impl Lock {
32
33
path,
33
34
options,
34
35
lock_file_path : None ,
36
+ forget : false ,
35
37
} )
36
38
}
37
39
@@ -56,6 +58,7 @@ impl Lock {
56
58
path,
57
59
options,
58
60
lock_file_path : Some ( lock_path) ,
61
+ forget : false ,
59
62
} )
60
63
}
61
64
@@ -84,10 +87,18 @@ impl Lock {
84
87
} ;
85
88
Ok ( Guard { lock, path } )
86
89
}
90
+
91
+ pub fn forget ( mut self ) {
92
+ self . forget = true ;
93
+ }
87
94
}
88
95
89
96
impl Drop for Lock {
90
97
fn drop ( & mut self ) {
98
+ if self . forget {
99
+ return ;
100
+ }
101
+
91
102
// check if we created a lock file
92
103
if let Some ( lock_file_path) = self . lock_file_path . take ( ) {
93
104
// try to get a write lock and delete file
Original file line number Diff line number Diff line change @@ -121,6 +121,11 @@ impl Lock {
121
121
path : Cow :: Borrowed ( & self . path ) ,
122
122
} )
123
123
}
124
+
125
+ pub fn forget ( self ) {
126
+ let _self = self ;
127
+ // no-op on windows
128
+ }
124
129
}
125
130
126
131
pub struct Guard < ' a > {
You can’t perform that action at this time.
0 commit comments