File tree 1 file changed +11
-1
lines changed
src/core/src/services/computer
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,11 @@ impl ComputerStorageEngine {
25
25
26
26
pub fn tasks ( & self , list_id : & str ) -> anyhow:: Result < Vec < Task > > {
27
27
let mut tasks = vec ! [ ] ;
28
- for entry in self . tasks_path ( ) . join ( list_id) . read_dir ( ) ? {
28
+ let path = self . tasks_path ( ) . join ( list_id) ;
29
+ if !path. exists ( ) {
30
+ return Ok ( tasks) ;
31
+ }
32
+ for entry in path. read_dir ( ) ? {
29
33
let entry = entry?;
30
34
let path = entry. path ( ) ;
31
35
let content = std:: fs:: read_to_string ( & path) ?;
@@ -37,6 +41,10 @@ impl ComputerStorageEngine {
37
41
38
42
pub fn lists ( & self ) -> anyhow:: Result < Vec < List > > {
39
43
let mut tasks = vec ! [ ] ;
44
+ let path = self . lists_path ( ) ;
45
+ if !path. exists ( ) {
46
+ return Ok ( tasks) ;
47
+ }
40
48
for entry in self . lists_path ( ) . read_dir ( ) ? {
41
49
let entry = entry?;
42
50
let path = entry. path ( ) ;
@@ -142,8 +150,10 @@ impl ComputerStorageEngine {
142
150
143
151
pub fn delete_list ( & self , list_id : & str ) -> anyhow:: Result < ( ) > {
144
152
let path = self . lists_path ( ) . join ( list_id) . with_extension ( "ron" ) ;
153
+ let tasks = self . tasks_path ( ) . join ( list_id) ;
145
154
if path. exists ( ) {
146
155
std:: fs:: remove_file ( path) ?;
156
+ std:: fs:: remove_dir_all ( tasks) ?;
147
157
Ok ( ( ) )
148
158
} else {
149
159
Err ( anyhow:: anyhow!( "List does not exist" ) )
You can’t perform that action at this time.
0 commit comments