Skip to content

Commit

Permalink
Merge pull request #24 from p-x9/feature/app-group-directories
Browse files Browse the repository at this point in the history
fix to handle files directory under the home directory
  • Loading branch information
p-x9 authored Oct 12, 2022
2 parents 092060e + 854dc73 commit 06d027d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/AppContainer/AppContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,17 @@ extension AppContainer {
/// - src: source path.
/// - dst: destination path.
private func moveContainerContents(src: String, dst: String) throws {
if src == dst {
return
}

if groupIdentifier != nil {
let excludes = Constants.appGroupExcludeFileNames + Container.Directories.allNames
try fileManager.createDirectoryIfNotExisted(atPath: dst, withIntermediateDirectories: true)
try fileManager.removeChildContents(atPath: dst, excludes: excludes)
try fileManager.moveChildContents(atPath: src, toPath: dst, excludes: excludes)
}

try Container.Directories.allCases.forEach { directory in
let source = src + "/" + directory.name
let destination = dst + "/" + directory.name
Expand Down
5 changes: 5 additions & 0 deletions Sources/AppContainer/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ enum Constants {
static let appContainerSettingsPlistName = "settings.plist"

static let containerInfoPlistName = "container.plist"

static let appGroupExcludeFileNames = [
".com.apple.mobile_container_manager.metadata.plist",
"container.plist"
]
}

0 comments on commit 06d027d

Please sign in to comment.