Skip to content

Commit 79a2d6b

Browse files
author
Anatoly Bolshakov
authored
Fixed issue with timestamp (#14856)
1 parent cc2f90f commit 79a2d6b

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

Tasks/CopyFilesV2/copyfiles.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ import fs = require('fs');
22
import path = require('path');
33
import tl = require('azure-pipelines-task-lib/task');
44

5+
/**
6+
* Shows timestamp change operation results
7+
* @param fileStats file stats
8+
* @param err error - null if there is no error
9+
*/
10+
function displayTimestampChangeResults(
11+
fileStats: tl.FsStats,
12+
err: NodeJS.ErrnoException
13+
) {
14+
if (err) {
15+
console.warn(`Problem applying the timestamp: ${err}`);
16+
} else {
17+
console.log(`Timestamp preserved successfully - access time: ${fileStats.atime}, modified time: ${fileStats.mtime}`)
18+
}
19+
}
520

621
// we allow broken symlinks - since there could be broken symlinks found in source folder, but filtered by contents pattern
722
const findOptions: tl.FindOptions = {
@@ -124,7 +139,7 @@ if (matchedFiles.length > 0) {
124139
try {
125140
const fileStats = tl.stats(file);
126141
fs.utimes(targetPath, fileStats.atime, fileStats.mtime, (err) => {
127-
console.warn(`Problem applying the timestamp: ${err}`);
142+
displayTimestampChangeResults(fileStats, err);
128143
});
129144
}
130145
catch (err) {
@@ -160,7 +175,7 @@ if (matchedFiles.length > 0) {
160175
try {
161176
const fileStats: tl.FsStats = tl.stats(file);
162177
fs.utimes(targetPath, fileStats.atime, fileStats.mtime, (err) => {
163-
console.warn(`Problem applying the timestamp: ${err}`);
178+
displayTimestampChangeResults(fileStats, err);
164179
});
165180
}
166181
catch (err) {

Tasks/CopyFilesV2/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"author": "Microsoft Corporation",
1717
"version": {
1818
"Major": 2,
19-
"Minor": 186,
20-
"Patch": 1
19+
"Minor": 188,
20+
"Patch": 0
2121
},
2222
"releaseNotes": "Match pattern consistency.",
2323
"demands": [],

Tasks/CopyFilesV2/task.loc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"author": "Microsoft Corporation",
1717
"version": {
1818
"Major": 2,
19-
"Minor": 186,
20-
"Patch": 1
19+
"Minor": 188,
20+
"Patch": 0
2121
},
2222
"releaseNotes": "ms-resource:loc.releaseNotes",
2323
"demands": [],

0 commit comments

Comments
 (0)