| 3159 | * @returns {boolean} true, if ok |
| 3160 | */ |
| 3161 | const checkFile = (path, c, s, log = true) => { |
| 3162 | if (c === s) return true; |
| 3163 | if (!checkExistence(path, Boolean(c), Boolean(s))) return false; |
| 3164 | if (c) { |
| 3165 | // For existing items only |
| 3166 | if (typeof startTime === "number" && c.safeTime > startTime) { |
| 3167 | // If a change happened after starting reading the item |
| 3168 | // this may no longer be valid |
| 3169 | if (log && this._remainingLogs > 0) { |
| 3170 | this._log( |
| 3171 | path, |
| 3172 | "it may have changed (%d) after the start time of the snapshot (%d)", |
| 3173 | c.safeTime, |
| 3174 | startTime |
| 3175 | ); |
| 3176 | } |
| 3177 | return false; |
| 3178 | } |
| 3179 | const snap = /** @type {FileSystemInfoEntry} */ (s); |
| 3180 | if (snap.timestamp !== undefined && c.timestamp !== snap.timestamp) { |
| 3181 | // If we have a timestamp (it was a file or symlink) and it differs from current timestamp |
| 3182 | // it's invalid |
| 3183 | if (log && this._remainingLogs > 0) { |
| 3184 | this._log( |
| 3185 | path, |
| 3186 | "timestamps differ (%d != %d)", |
| 3187 | c.timestamp, |
| 3188 | snap.timestamp |
| 3189 | ); |
| 3190 | } |
| 3191 | return false; |
| 3192 | } |
| 3193 | } |
| 3194 | return true; |
| 3195 | }; |
| 3196 | /** |
| 3197 | * Checks true, if ok. |
| 3198 | * @param {string} path file path |