<commit_before>import {DownloadModel} from "../../../shared/models/DownloadModel";
const UUID = require('uuid/v1');

class FtpFile {
    public static FTP_TYPE_FILE = 0;
    public static FTP_TYPE_DIRECTORY = 1;
    public static FTP_TYPE_SYM_LINK = 2;

    private _basePath: string;
    private _relativePath: string;
    private _timestamp: number;

    private _destinationRoot: string;

    private _key: string;

    /** @type FtpData */
    private _data: any;

    /** @type FtpData */
    private _targetData: any;

    private _transferred: number = 0;

    private _downloading: boolean = false;

    get directory(): string {
        return FtpFile.appendSlash(this._basePath) + FtpFile.appendSlash(this._relativePath)
    }

    get actualPath(): string {
        return FtpFile.appendSlash(this._basePath) + FtpFile.appendSlash(this._relativePath) + this._data.name;
    }

    get relativeDirectory(): string {
        return FtpFile.appendSlash(this._relativePath);
    }

    get fullPath(): string {
        return (this._data.hasOwnProperty("target")) ?
            //Use target if it's a symlink
            FtpFile.appendSlash(this._basePath) + FtpFile.appendSlash(this._relativePath) + this._data.target
            : this.actualPath
    }

    get destinationRoot(): string {
        return this._destinationRoot;
    }

    set destinationRoot(destinationRoot: string) {
        this._destinationRoot = destinationRoot;
    }

    get timestamp(): number {
        return this._timestamp;
    }
    
    get transferred(): number {
        return this._transferred;
    }

    set transferred(val: number) {
        this._transferred = val;
    }

    get name(): string {
        return this._data.name;
    }

    get isSymLink(): boolean {
        return this._data.type == 2;
    }

    get downloading(): boolean {
        return this._downloading;
    }

    set downloading(val: boolean) {
        this._downloading = val;

    }

    set targetData(data) {
        this._targetData = data;
    }

    get targetData(): any {
        return this._targetData;
    }

    constructor(basePath, relativePath, ftpData) {
        this._basePath = basePath;
        this._relativePath = relativePath;
        this._data = ftpData;
        this._timestamp = this._data.time;
        this._key = UUID();
    }

    toModel() {
        //TODO: Finish this data structure.
        var model = new DownloadModel();
        model.filename = this._data.name;
        model.sourceRoot = this._basePath;
        model.destRoot = this._destinationRoot;
        model.path = this._relativePath;
        model.downloadRate = this.transferred > 0 ? 1.21 : 0;
        model.status = this.downloading ? "downloading" : "queued";
        model.dateAdded = this._data.time;
        model.key = this._key;

        return model;
    }

    public equals(otherFile: FtpFile) : boolean {
        return this.fullPath == otherFile.fullPath;
    }

    /**
     *
     * @param {FtpFile} a
     * @param {FtpFile} b
     */
    static sortNewestFirst = function (a, b) {
        if (a._timestamp > b._timestamp) {
            return -1;
        }

        if (a._timestamp < b._timestamp) {<commit_msg>Fixing download size indicators on UI.<commit_after>import {DownloadModel} from "../../../shared/models/DownloadModel";
const UUID = require('uuid/v1');

class FtpFile {
    public static FTP_TYPE_FILE = 0;
    public static FTP_TYPE_DIRECTORY = 1;
    public static FTP_TYPE_SYM_LINK = 2;

    private _basePath: string;
    private _relativePath: string;
    private _timestamp: number;

    private _destinationRoot: string;

    private _key: string;

    /** @type FtpData */
    private _data: any;

    /** @type FtpData */
    private _targetData: any;

    private _transferred: number = 0;

    private _downloading: boolean = false;

    get directory(): string {
        return FtpFile.appendSlash(this._basePath) + FtpFile.appendSlash(this._relativePath)
    }

    get actualPath(): string {
        return FtpFile.appendSlash(this._basePath) + FtpFile.appendSlash(this._relativePath) + this._data.name;
    }

    get relativeDirectory(): string {
        return FtpFile.appendSlash(this._relativePath);
    }

    get fullPath(): string {
        return (this._data.hasOwnProperty("target")) ?
            //Use target if it's a symlink
            FtpFile.appendSlash(this._basePath) + FtpFile.appendSlash(this._relativePath) + this._data.target
            : this.actualPath
    }

    get destinationRoot(): string {
        return this._destinationRoot;
    }

    set destinationRoot(destinationRoot: string) {
        this._destinationRoot = destinationRoot;
    }

    get timestamp(): number {
        return this._timestamp;
    }
    
    get transferred(): number {
        return this._transferred;
    }

    set transferred(val: number) {
        this._transferred = val;
    }

    get name(): string {
        return this._data.name;
    }

    get isSymLink(): boolean {
        return this._data.type == 2;
    }

    get downloading(): boolean {
        return this._downloading;
    }

    set downloading(val: boolean) {
        this._downloading = val;

    }

    set targetData(data) {
        this._targetData = data;
    }

    get targetData(): any {
        return this._targetData;
    }

    constructor(basePath, relativePath, ftpData) {
        this._basePath = basePath;
        this._relativePath = relativePath;
        this._data = ftpData;
        this._timestamp = this._data.time;
        this._key = UUID();
    }

    toModel() {
        //TODO: Finish this data structure.
        var model = new DownloadModel();
        model.filename = this._data.name;
        model.sourceRoot = this._basePath;
        model.destRoot = this._destinationRoot;
        model.path = this._relativePath;
        model.size = this._targetData ? this._targetData.size : this._data.size;
        model.downloaded = this.transferred;
        model.downloadRate = this.transferred > 0 ? 1.21 : 0;
        model.status = this.downloading ? "downloading" : "queued";
        model.dateAdded = this._data.time;
        model.key = this._key;

        return model;
    }

    public equals(otherFile: FtpFile) : boolean {
        return this.fullPath == otherFile.fullPath;
    }

    /**
     *
     * @param {FtpFile} a
     * @param {FtpFile} b
     */
    static sortNewestFirst = function (a, b) {
        if (a._timestamp > b._timestamp) {
            return -1;
        }

        if (a._timestamp < b._timestamp) {
{'fraction_non_alphanumeric': 0.10867245846669715, 'fraction_numerical': 0.003657978966620942, 'mean_word_length': 2.2630532073595226, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3498904', 'n_tokens_mistral': 1984, 'n_tokens_neox': 1908, 'n_words': 439}