Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Copy Files] Fixed issue with timestamp #14856

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions Tasks/CopyFilesV2/copyfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ import fs = require('fs');
import path = require('path');
import tl = require('azure-pipelines-task-lib/task');

/**
* Shows timestamp change operation results
* @param fileStats file stats
* @param err error - null if there is no error
*/
function displayTimestampChangeResults(
fileStats: tl.FsStats,
err: NodeJS.ErrnoException
) {
if (err) {
console.warn(`Problem applying the timestamp: ${err}`);
} else {
console.log(`Timestamp preserved successfully - access time: ${fileStats.atime}, modified time: ${fileStats.mtime}`)
}
}

// we allow broken symlinks - since there could be broken symlinks found in source folder, but filtered by contents pattern
const findOptions: tl.FindOptions = {
Expand Down Expand Up @@ -124,7 +139,7 @@ if (matchedFiles.length > 0) {
try {
const fileStats = tl.stats(file);
fs.utimes(targetPath, fileStats.atime, fileStats.mtime, (err) => {
console.warn(`Problem applying the timestamp: ${err}`);
displayTimestampChangeResults(fileStats, err);
});
}
catch (err) {
Expand Down Expand Up @@ -160,7 +175,7 @@ if (matchedFiles.length > 0) {
try {
const fileStats: tl.FsStats = tl.stats(file);
fs.utimes(targetPath, fileStats.atime, fileStats.mtime, (err) => {
console.warn(`Problem applying the timestamp: ${err}`);
displayTimestampChangeResults(fileStats, err);
});
}
catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions Tasks/CopyFilesV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 186,
"Patch": 1
"Minor": 188,
"Patch": 0
},
"releaseNotes": "Match pattern consistency.",
"demands": [],
Expand Down
4 changes: 2 additions & 2 deletions Tasks/CopyFilesV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 186,
"Patch": 1
"Minor": 188,
"Patch": 0
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"demands": [],
Expand Down