Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import Foundation
/// - The spaceInPercentage is passed as 512 * 1024 * 1024 representing 512 MB of storage
/// - Then when isMet() is call it will yield true
/// - If the Free Space is now 500 MB
/// - It will again yeild true
/// - It will again yield true
/// - if the Free Space is now 513 MB
/// - It will yeild false
/// - It will yield false
public final class ExactStorageSpaceAvailabilityConstraint: CleanUpConstraint {

/// Comparitor of spaceInPercentage against availableSpaceInPercentage you can either pass and closure with float compared with float or you could pass any boolean operation like <=, >=, <,> as comparitors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import Foundation
/// - The spaceInPercentage is passed as 0.25 representing 25% of storage
/// - Then when isMet() is call it will yield true
/// - If the Free Space is now 24 GB
/// - It will again yeild true
/// - It will again yield true
/// - if the Free Space is now 26 GB
/// - It will yeild false
/// - It will yield false
public final class PercentageStorageSpaceAvailabilityConstraint: CleanUpConstraint {

/// Comparitor of spaceInPercentage against availableSpaceInPercentage you can either pass and closure with float compared with float or you could pass any boolean operation like <=, >=, <,> as comparitors
Expand Down
2 changes: 1 addition & 1 deletion StorageCleaner/Sources/Config/StorageCleanerConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public protocol StorageCleanerConfig {
/// This `Int64` value represents that limit (in bytes).
var cacheDirSizeLimitInBytes: Int64 { get set }

/// Interval in secods for periodic cleanup
/// Interval in seconds for periodic cleanup
var cleanUpInterval: TimeInterval { get set }

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public struct StorageCleanerDefaultConfig {
public static let cleanUpInterval: TimeInterval = 2 * 24 * 60 * 60
}

/// Represets default concrete implementation of ``StorageCleanerConfig``
/// Represents default concrete implementation of ``StorageCleanerConfig``
public struct StorageCleanerConfiguration: StorageCleanerConfig {

public var isEnabled: Bool = true
Expand Down
4 changes: 2 additions & 2 deletions StorageCleaner/Sources/DiskSpaceProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class DiskSpaceProvider {
return space ?? 0
}

/// Fetch the available according to provided usage tyep
/// Fetch the available according to provided usage type
/// - Parameter usageType: usage type of disk space
/// - Returns: returns size
public func getFreeDiskSpace(forUsageType usageType: UsageType) throws -> Int64 {
Expand All @@ -45,7 +45,7 @@ public class DiskSpaceProvider {
return size ?? 0
}

/// Get free disk space irrelevent to usage type iOS 13 prior API
/// Get free disk space irrelevant to usage type iOS 13 prior API
/// - Returns: returns size
public func getFreeDiskSpace() throws -> Int64 {
let systemAttributes = try FileManager.default.attributesOfFileSystem(forPath: homeDirectoryPath)
Expand Down
4 changes: 2 additions & 2 deletions StorageCleaner/Sources/Extensions/URL+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ enum FileTypeError: Error {

extension URL {

/// Return the size of content at url, it can be file size or diretory's meta data size
/// Return the size of content at url, it can be file size or directory's meta data size
/// - Returns: size of content in bytes
func getSizeOfContent() -> Int64 {
let size = try? FileManager.default.attributesOfItem(atPath: path)[.size] as? NSNumber
Expand All @@ -23,7 +23,7 @@ extension URL {
}

/// Returns last access date of that
/// - Returns: Date when the file assicoated with the url was last accessed
/// - Returns: Date when the file associated with the url was last accessed
func getLastAccessDate() -> Date? {
let resourceValues = try? resourceValues(forKeys: [.contentAccessDateKey])
return resourceValues?.contentAccessDate
Expand Down
8 changes: 4 additions & 4 deletions StorageCleaner/Sources/ItemRemovalResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ public class ItemRemovalResult {
public var freedSpaceInBytes: Int64
/// Space that was not able to be free after cleanup due to some errors in byte
public var unremovedItemsSpaceInBytes: Int64
/// URL's set that were succesfully removed
/// URL's set that were successfully removed
public var removedItemUris: Set<URL>
/// URL to error map for file that was not able to deleted due to errors
/// URL to error map for file that was not able to be deleted due to errors
public var unremovedItems: [URL: Error]

/// Creates ItemRemovalResult with provided attributes
/// - Parameters:
/// - freedSpaceInBytes: Space free by cleaner in bytes
/// - unremovedItemsSpaceInBytes: Space that was not able to be free after cleanup due to some errors in byte
/// - removedItemUris: URL's set that were succesfully removed
/// - unremovedItems: URL to error map for file that was not able to deleted due to errors
/// - removedItemUris: URL's set that were successfully removed
/// - unremovedItems: URL to error map for file that was not able to be deleted due to errors
public init(
freedSpaceInBytes: Int64,
unremovedItemsSpaceInBytes: Int64,
Expand Down
6 changes: 3 additions & 3 deletions StorageCleaner/Sources/RemovableItems/RemovableFiles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public final class RemovableFiles: RemovableItems {
/// Urls of files
var fileURls: [URL]

/// Count of elligible files
/// Count of eligible files
public var count: Int { fileURls.count }
lazy public var sizeInBytes: Int64 = {
return fileURls.reduce(0) { partialResult, url -> Int64 in
Expand Down Expand Up @@ -60,8 +60,8 @@ public final class RemovableFiles: RemovableItems {
return commit(shouldActuallyDelete: false)
}

/// Deletes the file depending on `shouldActuallyDelete` vauleu and genrates the removal result
/// - Parameter shouldActuallyDelete: if the action should commited or should just calculate the size that could have freed if deleted
/// Deletes the file depending on `shouldActuallyDelete` value and generates the removal result
/// - Parameter shouldActuallyDelete: if the action should committed or should just calculate the size that could have freed if deleted
/// - Returns: removal result
func commit(shouldActuallyDelete: Bool) -> ItemRemovalResult {
var removedUrls = Set<URL>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

/// AnalyticsResultReceiver is StorageCleanerResultReceiver's concerete implementation which is responsible to report removal result data points to provided performance tracker
/// AnalyticsResultReceiver is StorageCleanerResultReceiver's concrete implementation which is responsible to report removal result data points to provided performance tracker
public final class AnalyticsResultReceiver: StorageCleanerResultReceiver {

private let storageCleanerTrackingKey = "Disk Cleaner"
Expand All @@ -22,8 +22,8 @@ public final class AnalyticsResultReceiver: StorageCleanerResultReceiver {

/// AnalyticsResultReceiver init
///
/// AnalyticsResultReceiver is StorageCleanerResultReceiver's concerete implementation which is responsible to report removal result data points to provided performance tracker
/// - Parameter performanceTracker: performace tracker where the perfomance metric should be reported to
/// AnalyticsResultReceiver is StorageCleanerResultReceiver's concrete implementation which is responsible to report removal result data points to provided performance tracker
/// - Parameter performanceTracker: performance tracker where the performance metric should be reported to
public init?(performanceTracker: PerformanceTracker?, attributesMapProvider: (() -> [String: String])? = nil) {
guard let performanceTracker = performanceTracker else {
return nil
Expand Down
10 changes: 5 additions & 5 deletions StorageCleaner/Sources/StorageCleanerWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class StorageCleanerWorker {

/// Creates PercentageStorageSpaceAvailabilityConstraint
/// - Parameters:
/// - config: StorageCleanerConfig comforming object
/// - performanceTracker: PerformanceTracker comforming object
/// - config: StorageCleanerConfig conforming object
/// - performanceTracker: PerformanceTracker conforming object
/// - cacheRootDirectory: optional cacheRootDirectory description
public init(
config: StorageCleanerConfig,
Expand All @@ -45,7 +45,7 @@ public class StorageCleanerWorker {
.appendingPathComponent("fsCachedData")
}

// Exclude the designated file from rempvable items list
// Exclude the designated file from removable items list
private func excludingFilesFilter(_ file: URL) -> Bool {
return excludedFileList.contains(file.lastPathComponent) == false
}
Expand Down Expand Up @@ -73,7 +73,7 @@ public class StorageCleanerWorker {
diskSpaceProvider: diskSpaceProvider
),

// This envelopes get asked for removable items if the above contraint is met, this envelop contains sub envelop and when the removable item is called upon this it merges the result from sub enveloped
// This envelopes get asked for removable items if the above constraint is met, this envelop contains sub envelop and when the removable item is called upon this it merges the result from sub enveloped
delegate: StorageEnvelopes(

// This envelop fetches the stale files which are not used in the a set time duration
Expand All @@ -83,7 +83,7 @@ public class StorageCleanerWorker {
thresholdTimeInterval: config.cacheFileAgeLimitInTimeInterval
),

// This constraint only allows call to delegate evenloe if the current avaiaable space is <= to the space in byte provided
// This constraint only allows call to delegate envelope if the current available space is <= to the space in byte provided
ConstrainedEnvelopeProxy(
constraint: ExactStorageSpaceAvailabilityConstraint(
comparator: <=,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import Foundation

/// Directory Enveloper is responsible to collect removable files from provioded directory
/// Directory Enveloper is responsible to collect removable files from provided directory
public final class DirectoryEnvelope: StorageEnvelope {

/// Directory to fetchf file from, this directory is traversed in depth first fashion so the file included are also from relative subdirectories
/// Directory to fetch file from, this directory is traversed in depth first fashion so the file included are also from relative subdirectories
private var directoryURL: URL
/// File fileter to apply on collected file
private var filter: FileFilter? = nil
Expand All @@ -21,7 +21,7 @@ public final class DirectoryEnvelope: StorageEnvelope {

/// Creates a new DirectoryEnvelope
/// - Parameters:
/// - directoryURL: Directory to fetchf file from, this directory is traversed in depth first fashion so the file included are also from relative subdirectories
/// - directoryURL: Directory to fetch file from, this directory is traversed in depth first fashion so the file included are also from relative subdirectories
/// - filter: File fileter to apply on collected file
/// - fileComparator: File comparitor to sort the files
/// - sizeLimitInBytes: Size limit to trim the file limit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public final class LegacyStaleFilesEnvelope: StorageEnvelope {
return files
}

/// Checks the last accessed time vs the current time time diffrence and compare that with provided time interval to check if the file is stale
/// Checks the last accessed time vs the current time time difference and compare that with provided time interval to check if the file is stale
/// - Parameter fileURL: url of file
/// - Returns: returns true if file is stale otherwise false
private func isStale(_ fileURL: URL) -> Bool {
Expand Down