Skip to content

Commit

Permalink
Implement legacy import
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Dec 23, 2023
1 parent 265e0a9 commit a1e37a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/subject-manager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,23 @@ public class SubjectManager : Object {
return "-1";
}

public void read_data_legacy () {
public async void read_data_legacy () {
for (int i = 0; i < 20 && FileUtils.test (Environment.get_user_data_dir () + @"/gradebook/savedata/subjectsave$i", FileTest.EXISTS); i++) {
File file = File.new_for_path (Environment.get_user_data_dir () + @"/gradebook/savedata/subjectsave$i");

Subject sub = SubjectParser.to_object (read_from_file (file));
Subject sub = SubjectParser.legacy_to_object (read_from_file (file));
add_subject (sub);
try {
yield file.delete_async ();
} catch (Error e) {
warning ("Failed to delete old save file: %s", e.message);
}
}
}

public async void read_data () {
yield read_data_legacy ();

var keyfile = new KeyFile ();

try {
Expand Down Expand Up @@ -71,7 +78,6 @@ public class SubjectManager : Object {
continue;
}

keyfile.set_string (subject.name, "name", subject.name);
keyfile.set_string_list (subject.name, "categories", SubjectParser.categories_to_string_list (subject));
keyfile.set_string_list (subject.name, "grades", SubjectParser.grades_to_string_list (subject));
}
Expand Down
1 change: 0 additions & 1 deletion src/subject-parser.vala
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public class SubjectParser : Object {
root = node
};
result += generator.to_data (null);
print (generator.to_data (null));
}

return result;
Expand Down

0 comments on commit a1e37a2

Please sign in to comment.