mirror of
https://code.forgejo.org/forgejo/upload-artifact.git
synced 2024-11-22 08:22:40 +00:00
Correctly check symlinks (#103)
This commit is contained in:
parent
589ca5fbdd
commit
5f948bc1f0
2 changed files with 11 additions and 3 deletions
6
dist/index.js
vendored
6
dist/index.js
vendored
|
@ -6225,6 +6225,8 @@ const path = __importStar(__webpack_require__(622));
|
||||||
const core_1 = __webpack_require__(470);
|
const core_1 = __webpack_require__(470);
|
||||||
const fs_1 = __webpack_require__(747);
|
const fs_1 = __webpack_require__(747);
|
||||||
const path_1 = __webpack_require__(622);
|
const path_1 = __webpack_require__(622);
|
||||||
|
const util_1 = __webpack_require__(669);
|
||||||
|
const stats = util_1.promisify(fs_1.stat);
|
||||||
function getDefaultGlobOptions() {
|
function getDefaultGlobOptions() {
|
||||||
return {
|
return {
|
||||||
followSymbolicLinks: true,
|
followSymbolicLinks: true,
|
||||||
|
@ -6293,7 +6295,9 @@ function findFilesToUpload(searchPath, globOptions) {
|
||||||
directories so filter any directories out from the raw search results
|
directories so filter any directories out from the raw search results
|
||||||
*/
|
*/
|
||||||
for (const searchResult of rawSearchResults) {
|
for (const searchResult of rawSearchResults) {
|
||||||
if (!fs_1.lstatSync(searchResult).isDirectory()) {
|
const fileStats = yield stats(searchResult);
|
||||||
|
// isDirectory() returns false for symlinks if using fs.lstat(), make sure to use fs.stat() instead
|
||||||
|
if (!fileStats.isDirectory()) {
|
||||||
core_1.debug(`File:${searchResult} was found using the provided searchPath`);
|
core_1.debug(`File:${searchResult} was found using the provided searchPath`);
|
||||||
searchResults.push(searchResult);
|
searchResults.push(searchResult);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import * as glob from '@actions/glob'
|
import * as glob from '@actions/glob'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import {debug, info} from '@actions/core'
|
import {debug, info} from '@actions/core'
|
||||||
import {lstatSync} from 'fs'
|
import {stat} from 'fs'
|
||||||
import {dirname} from 'path'
|
import {dirname} from 'path'
|
||||||
|
import {promisify} from 'util'
|
||||||
|
const stats = promisify(stat)
|
||||||
|
|
||||||
export interface SearchResult {
|
export interface SearchResult {
|
||||||
filesToUpload: string[]
|
filesToUpload: string[]
|
||||||
|
@ -92,7 +94,9 @@ export async function findFilesToUpload(
|
||||||
directories so filter any directories out from the raw search results
|
directories so filter any directories out from the raw search results
|
||||||
*/
|
*/
|
||||||
for (const searchResult of rawSearchResults) {
|
for (const searchResult of rawSearchResults) {
|
||||||
if (!lstatSync(searchResult).isDirectory()) {
|
const fileStats = await stats(searchResult)
|
||||||
|
// isDirectory() returns false for symlinks if using fs.lstat(), make sure to use fs.stat() instead
|
||||||
|
if (!fileStats.isDirectory()) {
|
||||||
debug(`File:${searchResult} was found using the provided searchPath`)
|
debug(`File:${searchResult} was found using the provided searchPath`)
|
||||||
searchResults.push(searchResult)
|
searchResults.push(searchResult)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue