<commit_before>//
// Copyright (c) 2015 Zalando SE. All rights reserved.
//

import UIKit

public final class DiskStorage {

    public static let sharedStorage = DiskStorage()
    
    private let fileManager: NSFileManager = NSFileManager.defaultManager()
    private let storageQueue: dispatch_queue_t = dispatch_queue_create("de.zalando.MapleBacon.Storage", DISPATCH_QUEUE_SERIAL)
    private let storagePath: String

    public var maxAge: NSTimeInterval = 60 * 60 * 24 * 7

    public convenience init() {
        self.init(name: "default")
    }

    public init(name: String) {
        let paths = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true) as! [String]
        storagePath = paths.first!.stringByAppendingPathComponent("de.zalando.MapleBacon.\(name)")
        fileManager.createDirectoryAtPath(storagePath, withIntermediateDirectories: true, attributes: nil, error: nil)
    }

}

extension DiskStorage: Storage {
    
    public func storeImage(image: UIImage, var data: NSData?, forKey key: String) {
        dispatch_async(storageQueue) {
            if (data == nil) {
                data = UIImagePNGRepresentation(image)
            }
            self.fileManager.createFileAtPath(self.defaultStoragePath(forKey: key), contents: data!, attributes: nil)
            self.pruneStorage()<commit_msg>Redundant type information<commit_after>//
// Copyright (c) 2015 Zalando SE. All rights reserved.
//

import UIKit

public final class DiskStorage {

    public static let sharedStorage = DiskStorage()
    
    private let fileManager = NSFileManager.defaultManager()
    private let storageQueue = dispatch_queue_create("de.zalando.MapleBacon.Storage", DISPATCH_QUEUE_SERIAL)
    private let storagePath: String

    public var maxAge: NSTimeInterval = 60 * 60 * 24 * 7

    public convenience init() {
        self.init(name: "default")
    }

    public init(name: String) {
        let paths = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true) as! [String]
        storagePath = paths.first!.stringByAppendingPathComponent("de.zalando.MapleBacon.\(name)")
        fileManager.createDirectoryAtPath(storagePath, withIntermediateDirectories: true, attributes: nil, error: nil)
    }

}

extension DiskStorage: Storage {
    
    public func storeImage(image: UIImage, var data: NSData?, forKey key: String) {
        dispatch_async(storageQueue) {
            if (data == nil) {
                data = UIImagePNGRepresentation(image)
            }
            self.fileManager.createFileAtPath(self.defaultStoragePath(forKey: key), contents: data!, attributes: nil)
            self.pruneStorage()
{'fraction_non_alphanumeric': 0.09356287425149701, 'fraction_numerical': 0.008233532934131737, 'mean_word_length': 3.3891625615763545, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7146673', 'n_tokens_mistral': 797, 'n_tokens_neox': 752, 'n_words': 185}