Skip to content

Commit da3f52e

Browse files
author
tansansuisui
committed
Fix auto-save
1 parent b969d52 commit da3f52e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

OpenUtau.Core/DocManager.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,25 @@ private void CrashSave() {
150150
}
151151

152152
public void AutoSave() {
153-
if (Project == null || string.IsNullOrEmpty(Project.FilePath) || !Project.Saved) {
153+
if (Project == null) {
154154
return;
155155
}
156156
if (undoQueue.LastOrDefault() == autosavedPoint) {
157157
Log.Information("Autosave skipped.");
158158
return;
159159
}
160160
try {
161-
string dir = Path.GetDirectoryName(Project.FilePath);
162-
string filename = Path.GetFileNameWithoutExtension(Project.FilePath);
161+
bool untitled = string.IsNullOrEmpty(Project.FilePath);
162+
if (untitled) {
163+
Directory.CreateDirectory(PathManager.Inst.BackupsPath);
164+
}
165+
string dir = untitled
166+
? PathManager.Inst.BackupsPath
167+
: Path.GetDirectoryName(Project.FilePath);
168+
string filename = untitled
169+
? "Untitled"
170+
: Path.GetFileNameWithoutExtension(Project.FilePath);
171+
163172
string backup = Path.Join(dir, filename + "-autosave.ustx");
164173
Log.Information($"Autosave {backup}.");
165174
Format.Ustx.AutoSave(backup, Project);

0 commit comments

Comments
 (0)