artifact-engine 2.279.1 → 2.280.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Engine/artifactEngine.d.ts +2 -0
- package/Engine/artifactEngine.js +22 -1
- package/Models/artifactprovider.d.ts +1 -0
- package/Providers/filesystemCaseSensitivity.d.ts +13 -0
- package/Providers/filesystemCaseSensitivity.js +68 -0
- package/Providers/filesystemProvider.d.ts +3 -0
- package/Providers/filesystemProvider.js +15 -0
- package/package.json +1 -1
|
@@ -4,9 +4,11 @@ export declare class ArtifactEngine {
|
|
|
4
4
|
processItems(sourceProvider: models.IArtifactProvider, destProvider: models.IArtifactProvider, artifactEngineOptions?: ArtifactEngineOptions): Promise<models.ArtifactDownloadTicket[]>;
|
|
5
5
|
processArtifactItem(sourceProvider: models.IArtifactProvider, item: models.ArtifactItem, destProvider: models.IArtifactProvider, artifactEngineOptions: ArtifactEngineOptions): Promise<void>;
|
|
6
6
|
processArtifactItemImplementation(sourceProvider: models.IArtifactProvider, item: models.ArtifactItem, destProvider: models.IArtifactProvider, artifactEngineOptions: ArtifactEngineOptions, resolve: any, reject: any, retryCount?: number): void;
|
|
7
|
+
private isCaseInsensitiveArtifactMatchingEnabled;
|
|
7
8
|
private getRetryIntervalInSeconds;
|
|
8
9
|
createPatternList(artifactEngineOptions: ArtifactEngineOptions): void;
|
|
9
10
|
private artifactItemStore;
|
|
10
11
|
private logger;
|
|
11
12
|
private patternList;
|
|
13
|
+
private isCaseInsensitiveArtifactMatching;
|
|
12
14
|
}
|
package/Engine/artifactEngine.js
CHANGED
|
@@ -12,12 +12,15 @@ const worker_1 = require("./worker");
|
|
|
12
12
|
class ArtifactEngine {
|
|
13
13
|
constructor() {
|
|
14
14
|
this.artifactItemStore = new artifactItemStore_1.ArtifactItemStore();
|
|
15
|
+
this.isCaseInsensitiveArtifactMatching = false;
|
|
15
16
|
}
|
|
16
17
|
processItems(sourceProvider, destProvider, artifactEngineOptions) {
|
|
17
18
|
var artifactDownloadTicketsPromise = new Promise((resolve, reject) => {
|
|
18
19
|
const workers = [];
|
|
19
20
|
artifactEngineOptions = artifactEngineOptions || new artifactEngineOptions_1.ArtifactEngineOptions();
|
|
20
21
|
this.createPatternList(artifactEngineOptions);
|
|
22
|
+
this.isCaseInsensitiveArtifactMatching =
|
|
23
|
+
this.isCaseInsensitiveArtifactMatchingEnabled(destProvider);
|
|
21
24
|
this.artifactItemStore.flush();
|
|
22
25
|
logger_1.Logger.verbose = artifactEngineOptions.verbose;
|
|
23
26
|
this.logger = new logger_1.Logger(this.artifactItemStore);
|
|
@@ -79,7 +82,7 @@ class ArtifactEngine {
|
|
|
79
82
|
noglobstar: false,
|
|
80
83
|
dot: true,
|
|
81
84
|
noext: false,
|
|
82
|
-
nocase:
|
|
85
|
+
nocase: this.isCaseInsensitiveArtifactMatching,
|
|
83
86
|
nonull: false,
|
|
84
87
|
matchBase: false,
|
|
85
88
|
nocomment: false,
|
|
@@ -139,6 +142,24 @@ class ArtifactEngine {
|
|
|
139
142
|
});
|
|
140
143
|
}
|
|
141
144
|
}
|
|
145
|
+
isCaseInsensitiveArtifactMatchingEnabled(destProvider) {
|
|
146
|
+
if (!tl.getPipelineFeature('CaseInsensitiveArtifactMatchingFixEnabled')) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
if (process.platform === 'win32') {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
if (process.platform !== 'darwin' || !destProvider.isCaseInsensitiveFilesystem) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
return destProvider.isCaseInsensitiveFilesystem();
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
// Filesystem detection is advisory; preserve case-sensitive matching if it cannot run.
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
142
163
|
getRetryIntervalInSeconds(baseRetryInterval, retryCount) {
|
|
143
164
|
let MaxRetryLimitInSeconds = 360;
|
|
144
165
|
var exponentialBackOff = baseRetryInterval * Math.pow(3, (retryCount + 1));
|
|
@@ -7,5 +7,6 @@ export interface IArtifactProvider {
|
|
|
7
7
|
getArtifactItems(artifactItem: ArtifactItem): Promise<ArtifactItem[]>;
|
|
8
8
|
getArtifactItem(artifactItem: ArtifactItem): Promise<NodeJS.ReadableStream>;
|
|
9
9
|
putArtifactItem(artifactItem: ArtifactItem, stream: NodeJS.ReadableStream): Promise<ArtifactItem>;
|
|
10
|
+
isCaseInsensitiveFilesystem?(): boolean;
|
|
10
11
|
dispose(): void;
|
|
11
12
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface FileSystemCaseSensitivityProbe {
|
|
2
|
+
existsSync(path: string): boolean;
|
|
3
|
+
readdirSync(path: string): string[];
|
|
4
|
+
statSync(path: string): {
|
|
5
|
+
dev: number;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export interface PathOperations {
|
|
9
|
+
resolve(...paths: string[]): string;
|
|
10
|
+
dirname(path: string): string;
|
|
11
|
+
join(...paths: string[]): string;
|
|
12
|
+
}
|
|
13
|
+
export declare function isFilesystemCaseInsensitive(destinationPath: string, fileSystem?: FileSystemCaseSensitivityProbe, pathOperations?: PathOperations): boolean;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFilesystemCaseInsensitive = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
// Detect case behavior without creating a probe file. Probe only inside the nearest existing
|
|
7
|
+
// destination ancestor. Empty directories may ascend only within the same device.
|
|
8
|
+
function isFilesystemCaseInsensitive(destinationPath, fileSystem = fs, pathOperations = path) {
|
|
9
|
+
if (!destinationPath) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
let existingPath = pathOperations.resolve(destinationPath);
|
|
14
|
+
while (true) {
|
|
15
|
+
if (fileSystem.existsSync(existingPath)) {
|
|
16
|
+
const caseSensitivity = probeDirectoryCaseSensitivity(existingPath, fileSystem, pathOperations);
|
|
17
|
+
if (caseSensitivity !== null) {
|
|
18
|
+
return caseSensitivity;
|
|
19
|
+
}
|
|
20
|
+
const parentPath = pathOperations.dirname(existingPath);
|
|
21
|
+
if (parentPath === existingPath) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (fileSystem.statSync(existingPath).dev !== fileSystem.statSync(parentPath).dev) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
existingPath = parentPath;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const parentPath = pathOperations.dirname(existingPath);
|
|
31
|
+
if (parentPath === existingPath) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
existingPath = parentPath;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
// A false negative only retains the original case-sensitive behavior.
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.isFilesystemCaseInsensitive = isFilesystemCaseInsensitive;
|
|
43
|
+
function probeDirectoryCaseSensitivity(directoryPath, fileSystem, pathOperations) {
|
|
44
|
+
const entries = fileSystem.readdirSync(directoryPath);
|
|
45
|
+
for (const entry of entries) {
|
|
46
|
+
const caseVariant = getCaseVariant(entry);
|
|
47
|
+
if (!caseVariant) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (entries.filter((candidate) => candidate.toLowerCase() === entry.toLowerCase()).length !== 1) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return fileSystem.existsSync(pathOperations.join(directoryPath, caseVariant));
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
function getCaseVariant(pathSegment) {
|
|
58
|
+
for (let index = 0; index < pathSegment.length; index++) {
|
|
59
|
+
const character = pathSegment.charAt(index);
|
|
60
|
+
if (character >= 'a' && character <= 'z') {
|
|
61
|
+
return pathSegment.substring(0, index) + character.toUpperCase() + pathSegment.substring(index + 1);
|
|
62
|
+
}
|
|
63
|
+
if (character >= 'A' && character <= 'Z') {
|
|
64
|
+
return pathSegment.substring(0, index) + character.toLowerCase() + pathSegment.substring(index + 1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
@@ -8,8 +8,11 @@ export declare class FilesystemProvider implements models.IArtifactProvider {
|
|
|
8
8
|
getArtifactItems(artifactItem: models.ArtifactItem): Promise<models.ArtifactItem[]>;
|
|
9
9
|
getArtifactItem(artifactItem: models.ArtifactItem): Promise<NodeJS.ReadableStream>;
|
|
10
10
|
putArtifactItem(item: models.ArtifactItem, stream: NodeJS.ReadableStream): Promise<models.ArtifactItem>;
|
|
11
|
+
isCaseInsensitiveFilesystem(): boolean;
|
|
11
12
|
dispose(): void;
|
|
12
13
|
private getItems;
|
|
13
14
|
private _rootLocation;
|
|
14
15
|
private _rootItemPath;
|
|
16
|
+
private _hasDeterminedFilesystemCaseSensitivity;
|
|
17
|
+
private _isCaseInsensitiveFilesystem;
|
|
15
18
|
}
|
|
@@ -5,9 +5,12 @@ const path = require("path");
|
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const models = require("../Models");
|
|
7
7
|
const logger_1 = require("../Engine/logger");
|
|
8
|
+
const filesystemCaseSensitivity_1 = require("./filesystemCaseSensitivity");
|
|
8
9
|
var tl = require('azure-pipelines-task-lib');
|
|
9
10
|
class FilesystemProvider {
|
|
10
11
|
constructor(rootLocation, rootItemPath) {
|
|
12
|
+
this._hasDeterminedFilesystemCaseSensitivity = false;
|
|
13
|
+
this._isCaseInsensitiveFilesystem = false;
|
|
11
14
|
this._rootLocation = rootLocation;
|
|
12
15
|
this._rootItemPath = rootItemPath ? rootItemPath : '';
|
|
13
16
|
}
|
|
@@ -98,6 +101,18 @@ class FilesystemProvider {
|
|
|
98
101
|
}
|
|
99
102
|
});
|
|
100
103
|
}
|
|
104
|
+
isCaseInsensitiveFilesystem() {
|
|
105
|
+
if (!this._hasDeterminedFilesystemCaseSensitivity) {
|
|
106
|
+
try {
|
|
107
|
+
this._isCaseInsensitiveFilesystem = (0, filesystemCaseSensitivity_1.isFilesystemCaseInsensitive)(this._rootLocation);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
this._isCaseInsensitiveFilesystem = false;
|
|
111
|
+
}
|
|
112
|
+
this._hasDeterminedFilesystemCaseSensitivity = true;
|
|
113
|
+
}
|
|
114
|
+
return this._isCaseInsensitiveFilesystem;
|
|
115
|
+
}
|
|
101
116
|
dispose() {
|
|
102
117
|
}
|
|
103
118
|
getItems(itemsPath, parentRelativePath) {
|