<commit_before>#import 'sandbox.js'

var app = NSApplication.sharedApplication();

var temp = {};

var dockpreview = {
    createFolder: function (path) {
        var file_manager = [NSFileManager defaultManager];
        this.runMethodSandbox(path, function () {
            [file_manager createDirectoryAtURL:path
                withIntermediateDirectories:true
                attributes:nil
                error:nil];
        });
    },

    createTempFolder: function() {
        var guid = NSProcessInfo.processInfo().globallyUniqueString();
        var tmpPath = NSTemporaryDirectory();
        tmpPath = tmpPath.stringByAppendingPathComponent(guid);
        var tmpURL = [NSURL fileURLWithPath:tmpPath isDirectory:true];
        this.createFolder(tmpURL);
        temp.path = tmpPath;
    },

    setAppIconImage: function() {
        var artboard = this.getCurrentArtboard(),
        imgFile = temp.path + '/dockpreview-preview.png';
        this.runMethodSandbox(imgFile, function () {
            [doc saveArtboardOrSlice:artboard toFile:imgFile];
        });
        var img = NSImage.alloc().initByReferencingFile(imgFile);
        [app setApplicationIconImage:img];
    },

    restoreAppIconImage: function () {
        var bundle = NSBundle.mainBundle(),
            icon;
        if (app.applicationName() === 'Sketch Beta') {
            icon = [bundle pathForResource:@"beta" ofType:@"icns"];
        } else {
            icon = [bundle pathForResource:@"app" ofType:@"icns"];
        }
        img = NSImage.alloc().initByReferencingFile(icon);
        [app setApplicationIconImage:img];
    },

    getCurrentArtboard: function () {
        var page = [doc currentPage]
        return [page currentArtboard];
    },

    runMethodSandbox: function(path, method) {
        if(in_sandbox()) {
            sandboxAccess.accessFilePath_withBlock_persistPermission(path, method, true);
        } else {
            method();
        }
    }
};

dockpreview.createTempFolder();
<commit_msg>Really fixes #3<commit_after>#import 'sandbox.js'

var app = NSApplication.sharedApplication();

var temp = {};

var dockpreview = {
    createFolder: function (path) {
        var file_manager = [NSFileManager defaultManager];
        this.runMethodSandbox(path, function () {
            [file_manager createDirectoryAtURL:path
                withIntermediateDirectories:true
                attributes:nil
                error:nil];
        });
    },

    createTempFolder: function() {
        var guid = NSProcessInfo.processInfo().globallyUniqueString();
        var tmpPath = NSTemporaryDirectory();
        tmpPath = tmpPath.stringByAppendingPathComponent(guid);
        var tmpURL = [NSURL fileURLWithPath:tmpPath isDirectory:true];
        this.createFolder(tmpURL);
        temp.path = tmpPath;
    },

    setAppIconImage: function() {
        var artboard = this.getCurrentArtboard(),
        imgFile = temp.path + '/dockpreview-preview.png';
        this.runMethodSandbox(imgFile, function () {
            [doc saveArtboardOrSlice:artboard toFile:imgFile];
        });
        var img = NSImage.alloc().initByReferencingFile(imgFile);
        [app setApplicationIconImage:img];
    },

    restoreAppIconImage: function () {
        var bundle = NSBundle.mainBundle(),
            icon;
        if (app.applicationName() == 'Sketch Beta') {
            icon = [bundle pathForResource:@"beta" ofType:@"icns"];
        } else {
            icon = [bundle pathForResource:@"app" ofType:@"icns"];
        }
        img = NSImage.alloc().initByReferencingFile(icon);
        [app setApplicationIconImage:img];
    },

    getCurrentArtboard: function () {
        var page = [doc currentPage]
        return [page currentArtboard];
    },

    runMethodSandbox: function(path, method) {
        if(in_sandbox()) {
            sandboxAccess.accessFilePath_withBlock_persistPermission(path, method, true);
        } else {
            method();
        }
    }
};

dockpreview.createTempFolder();

{'fraction_non_alphanumeric': 0.11407222914072229, 'fraction_numerical': 0.00024906600249066, 'mean_word_length': 2.5135608048993876, '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': '4389241', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1089, 'n_words': 204}