finki-main
main
|
Last change
on this file since 62b2964 was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago |
|
Initial commit
|
-
Property mode
set to
100644
|
|
File size:
937 bytes
|
| Line | |
|---|
| 1 | 'use strict'
|
|---|
| 2 |
|
|---|
| 3 | // tar -u
|
|---|
| 4 |
|
|---|
| 5 | const hlo = require('./high-level-opt.js')
|
|---|
| 6 | const r = require('./replace.js')
|
|---|
| 7 | // just call tar.r with the filter and mtimeCache
|
|---|
| 8 |
|
|---|
| 9 | module.exports = (opt_, files, cb) => {
|
|---|
| 10 | const opt = hlo(opt_)
|
|---|
| 11 |
|
|---|
| 12 | if (!opt.file) {
|
|---|
| 13 | throw new TypeError('file is required')
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | if (opt.gzip || opt.brotli || opt.file.endsWith('.br') || opt.file.endsWith('.tbr')) {
|
|---|
| 17 | throw new TypeError('cannot append to compressed archives')
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | if (!files || !Array.isArray(files) || !files.length) {
|
|---|
| 21 | throw new TypeError('no files or directories specified')
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | files = Array.from(files)
|
|---|
| 25 |
|
|---|
| 26 | mtimeFilter(opt)
|
|---|
| 27 | return r(opt, files, cb)
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | const mtimeFilter = opt => {
|
|---|
| 31 | const filter = opt.filter
|
|---|
| 32 |
|
|---|
| 33 | if (!opt.mtimeCache) {
|
|---|
| 34 | opt.mtimeCache = new Map()
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | opt.filter = filter ? (path, stat) =>
|
|---|
| 38 | filter(path, stat) && !(opt.mtimeCache.get(path) > stat.mtime)
|
|---|
| 39 | : (path, stat) => !(opt.mtimeCache.get(path) > stat.mtime)
|
|---|
| 40 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.