Last change
on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
842 bytes
|
Rev | Line | |
---|
[6a3a178] | 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 | if (opt.gzip)
|
---|
| 16 | throw new TypeError('cannot append to compressed archives')
|
---|
| 17 |
|
---|
| 18 | if (!files || !Array.isArray(files) || !files.length)
|
---|
| 19 | throw new TypeError('no files or directories specified')
|
---|
| 20 |
|
---|
| 21 | files = Array.from(files)
|
---|
| 22 |
|
---|
| 23 | mtimeFilter(opt)
|
---|
| 24 | return r(opt, files, cb)
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | const mtimeFilter = opt => {
|
---|
| 28 | const filter = opt.filter
|
---|
| 29 |
|
---|
| 30 | if (!opt.mtimeCache)
|
---|
| 31 | opt.mtimeCache = new Map()
|
---|
| 32 |
|
---|
| 33 | opt.filter = filter ? (path, stat) =>
|
---|
| 34 | filter(path, stat) && !(opt.mtimeCache.get(path) > stat.mtime)
|
---|
| 35 | : (path, stat) => !(opt.mtimeCache.get(path) > stat.mtime)
|
---|
| 36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.