Skip to content

Commit

Permalink
chore: PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-coye committed Jul 12, 2023
1 parent 0c23627 commit bfc214b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions Sources/InfomaniakCore/FileManagement/AppGroupPathProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ import OSLog
/// This is shared between all apps of the group initialised with
public protocol AppGroupPathProvidable: AnyObject {
/// Failable init if app group is not found
init?(appGroupIdentifier: String)
init?(realmRootPath: String, appGroupIdentifier: String)

/// The directory of the current app group, exists in FS.
/// Uses the `.completeUntilFirstUserAuthentication` protection policy
var groupDirectoryURL: URL { get }

/// The root directory of kDrive, exists in FS
var driveRootDocumentsURL: URL { get }
/// The root directory to store the App's Realm files, exists in FS
var realmRootURL: URL { get }

/// The import directory, exists in FS
var importDirectoryURL: URL { get }
Expand All @@ -51,12 +51,14 @@ public protocol AppGroupPathProvidable: AnyObject {
public final class AppGroupPathProvider: AppGroupPathProvidable {
private var fileManager = FileManager.default

private var realmRootPath: String

// MARK: public var

public var groupDirectoryURL: URL

public lazy var driveRootDocumentsURL: URL = {
let drivesURL = groupDirectoryURL.appendingPathComponent("drives", isDirectory: true)
public lazy var realmRootURL: URL = {
let drivesURL = groupDirectoryURL.appendingPathComponent(self.realmRootPath, isDirectory: true)
try? fileManager.createDirectory(
atPath: drivesURL.path,
withIntermediateDirectories: true,
Expand Down Expand Up @@ -102,8 +104,8 @@ public final class AppGroupPathProvider: AppGroupPathProvidable {
}()

// MARK: init
public init?(appGroupIdentifier: String) {

public init?(realmRootPath: String, appGroupIdentifier: String) {
guard let groupDirectoryURL = fileManager.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier)
else {
return nil
Expand All @@ -120,6 +122,7 @@ public final class AppGroupPathProvider: AppGroupPathProvidable {
}

self.groupDirectoryURL = groupDirectoryURL
self.realmRootPath = realmRootPath
}
}

Expand Down

0 comments on commit bfc214b

Please sign in to comment.