Skip to content

Commit

Permalink
Add defense for a corner case
Browse files Browse the repository at this point in the history
  • Loading branch information
livid committed Oct 9, 2024
1 parent 5664638 commit 45b128d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Planet/Entities/MyArticleModel+Save.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ extension MyArticleModel {
var marks: OrderedDictionary<String, Date> = ["Started": started]

removeDSStore()

if !FileManager.default.fileExists(atPath: publicBasePath.path) {
try FileManager.default.createDirectory(at: publicBasePath, withIntermediateDirectories: true)
}

saveMarkdownInBackground()

try processContent()
Expand Down
3 changes: 3 additions & 0 deletions Planet/Entities/MyPlanetModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,9 @@ class MyPlanetModel: Equatable, Hashable, Identifiable, ObservableObject, Codabl
guard let template = template else {
throw PlanetError.MissingTemplateError
}
if !FileManager.default.fileExists(atPath: publicBasePath.path) {
try FileManager.default.createDirectory(at: publicBasePath, withIntermediateDirectories: true)
}
if FileManager.default.fileExists(atPath: publicAssetsPath.path) {
try FileManager.default.removeItem(at: publicAssetsPath)
}
Expand Down

0 comments on commit 45b128d

Please sign in to comment.