(collectKey, thisFile)
| 911 | } |
| 912 | |
| 913 | #fileStats(collectKey, thisFile) { |
| 914 | const folderLoc = this.#map_CollectionToFolder[collectKey] |
| 915 | const fullPath = path.join(folderLoc, thisFile.name) |
| 916 | const fileStats = { |
| 917 | birthDate : null, |
| 918 | date : null, |
| 919 | error : false, |
| 920 | fullPath : fullPath, |
| 921 | hashString : null, |
| 922 | isFolder : null, |
| 923 | size : null, |
| 924 | } |
| 925 | |
| 926 | let isSymLink = null |
| 927 | |
| 928 | try { |
| 929 | if ( thisFile.isSymbolicLink() ) { |
| 930 | const thisSymLink = fs.readlinkSync(fullPath) |
| 931 | const thisSymLinkStat = fs.lstatSync(path.join(folderLoc, thisSymLink)) |
| 932 | |
| 933 | isSymLink = path.join(folderLoc, thisSymLink) |
| 934 | |
| 935 | fileStats.isFolder = thisSymLinkStat.isDirectory() |
| 936 | fileStats.date = thisSymLinkStat.ctime |
| 937 | fileStats.birthDate = thisSymLinkStat.birthtime |
| 938 | |
| 939 | if ( !fileStats.isFolder ) { fileStats.size = thisSymLinkStat.size } |
| 940 | } else { |
| 941 | const theseStats = fs.statSync(fullPath) |
| 942 | |
| 943 | fileStats.isFolder = thisFile.isDirectory() |
| 944 | fileStats.date = theseStats.ctime |
| 945 | fileStats.birthDate = theseStats.birthtime |
| 946 | |
| 947 | if ( !fileStats.isFolder ) { fileStats.size = theseStats.size } |
| 948 | } |
| 949 | |
| 950 | if ( fileStats.isFolder ) { |
| 951 | fileStats.size = globSync('**', { cwd : (isSymLink !== null ? isSymLink : fullPath), stat : true, withFileTypes : true }).filter((x) => x.isFile()).map((x) => x.size).reduce((total, x) => total + x, 0) |
| 952 | } else { |
| 953 | fileStats.hashString = this.#getMD5Hash(`${thisFile.name}-${fileStats.size}-${fileStats.birthDate.toISOString()}`) |
| 954 | } |
| 955 | } catch (err) { |
| 956 | this.#log.warning('collection-reader', `Unable to stat file ${thisFile.name} in ${folderLoc}`, err) |
| 957 | fileStats.isFolder = false |
| 958 | fileStats.size = 0 |
| 959 | fileStats.date = new Date(1969, 1, 1, 0, 0, 0, 0) |
| 960 | fileStats.birthDate = new Date(1969, 1, 1, 0, 0, 0, 0) |
| 961 | fileStats.error = true |
| 962 | } |
| 963 | return fileStats |
| 964 | } |
| 965 | |
| 966 | #util_between(low, check, high) { return ( check >= low && check <= high ) } |
| 967 | #util_gameVersion(dVer) { |
no test coverage detected