<commit_before>(() => {
    'use strict';

    const ds = require('data-service');

    /**
     * @param {ng.IScope} $scope
     * @param {*} exportStorageService
     * @param {$log} $log
     * @param {Storage} storage
     * @param {User} user
     * @param {*} utils
     * @param {*} $state
     * @param {*} configService
     * @param {*} modalManager
     */
    const controller = ($scope,
                        $state,
                        configService,
                        exportStorageService,
                        $log,
                        storage,
                        user,
                        utils,
                        modalManager) => {
        class DesktopUpdateCtrl {

            /**
             * @type {'askDownload' | 'downloading' | 'installAndRun' | 'success' | 'fail' }
             */
            state = 'askDownload';
            progress = 0;
            error = null;
            isDownloading = false;
            _oldDesktop = false;
            _hasAccounts = false;
            _isCanceled = null;

            constructor() {
                if (!WavesApp.isDesktop()) {
                    $state.go(user.getActiveState('wallet'));
                }

                this._oldDesktop = utils.isVersionLte('1.4.0');
                this._showMoving = !this._oldDesktop;

                storage.load('userList').then(list => {
                    if (list && list.length > 0) {
                        this._hasAccounts = true;
                    }
                });

                // this._export();
            }

            tryExport() {
                const win = window.open('http://localhost:8888');
                setTimeout(() => {
                    const connectProvider = this._getConnectProvider(win);

                    exportStorageService.export({
                        provider: connectProvider,
                        attempts: 1000,
                        timeout: 500
                    });

                    exportStorageService.onData().then(result => {
                        win.close();

                        if (result.payload === 'ok') {
                            $log.log('done');
                            this.state = 'success';
                            $scope.$apply();

                            return storage.save('migrationSuccess', true);
                        } else {
                            win.close();

                            this.state = 'fail';

                            return storage.save('migrationSuccess', false);
                        }
                    });
                });
            }

            _export() {<commit_msg>DEXW-2225: Fix fail case<commit_after>(() => {
    'use strict';

    const ds = require('data-service');

    /**
     * @param {ng.IScope} $scope
     * @param {*} exportStorageService
     * @param {$log} $log
     * @param {Storage} storage
     * @param {User} user
     * @param {*} utils
     * @param {*} $state
     * @param {*} configService
     * @param {*} modalManager
     */
    const controller = ($scope,
                        $state,
                        configService,
                        exportStorageService,
                        $log,
                        storage,
                        user,
                        utils,
                        modalManager) => {
        class DesktopUpdateCtrl {

            /**
             * @type {'askDownload' | 'downloading' | 'installAndRun' | 'success' | 'fail' }
             */
            state = 'askDownload';
            progress = 0;
            error = null;
            isDownloading = false;
            _oldDesktop = false;
            _hasAccounts = false;
            _isCanceled = null;

            constructor() {
                if (!WavesApp.isDesktop()) {
                    $state.go(user.getActiveState('wallet'));
                }

                this._oldDesktop = utils.isVersionLte('1.4.0');
                this._showMoving = !this._oldDesktop;

                storage.load('userList').then(list => {
                    if (list && list.length > 0) {
                        this._hasAccounts = true;
                    }
                });

                // this._export();
            }

            tryExport() {
                const win = window.open('http://localhost:8888');
                setTimeout(() => {
                    window.addEventListener('message', event => {
                        if (event.data.migrationError) {
                            win.close();
                            this.state = 'fail';
                            return storage.save('migrationSuccess', false);
                        } else {
                            const connectProvider = this._getConnectProvider(win);

                            exportStorageService.export({
                                provider: connectProvider,
                                attempts: 1000,
                                timeout: 500
                            });

                            exportStorageService.onData().then(result => {
                                win.close();

                                if (result.payload === 'ok') {
                                    $log.log('done');
                                    this.state = 'success';
                                    $scope.$apply();

                                    return storage.save('migrationSuccess', true);
                                } else {
                                    win.close();
                                    this.state = 'fail';
                                    return storage.save('migrationSuccess', false);
                                }
                            });
                        }
                    });
                    const content = '{migrationError: !!window.location.href.includes(\'error\') }';
                    win.eval(`window.opener.postMessage(${content}, '*')`);
                });
            }

            _export() {
{'fraction_non_alphanumeric': 0.11180327868852459, 'fraction_numerical': 0.005901639344262295, 'mean_word_length': 0.8970771144278606, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 17, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6611997', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1314, 'n_words': 243}