Skip to content

Doesn't seem to support uploading a directory tree? #1113

Description

@mattj65817

Is it me, or could this never possibly work to upload a tree of directories that is >1 level deep?

for (const dir of config.directories) {
        info(`--> Uploading directory ${dir} (excluded: ${excluded.includes(dir)})`);
        if (excluded.includes(dir)) continue;

        const globber = await createGlobPattern(dir, { followSymbolicLinks: config.followSymlinks });
        for await (const d of globber.globGenerator()) {
            const stats = await lstat(d);
            if (!stats.isDirectory()) {
                warning(`Path ${d} is not a directory, skipping!`);
                continue;
            }

            const files = await readdir(d).then((files) => files.map((s) => join(d, s)));
            for (const file of files) {
                debug(`Uploading file ${file} (from directory ${d})`);
                if (excluded.includes(file)) continue;

                await upload({
                    pathFormat: config.pathFormat,
                    partSize: config.partSize,
                    prefix: config.prefix,
                    bucket: config.bucket,
                    stream: createReadStream(file),
                    file: basename(file),
                    acl: config.objectAcl
                });

The issue appears to be in const files = await readdir(d).then((files) => files.map((s) => join(d, s)));.

  1. We glob for directories matching the directories config.
  2. We read each matched directory and assume every entry in it is a file (not a subdirectory) and try to upload it as a file.
  3. If any entry is not a file, is a directory, we blow up with Error: failed to run noelware/s3-action: Error: EISDIR: illegal operation on a directory, read

I feel like I have to be missing something, I don't know how you get to a version 2.x without uncovering an error like this. It seems like a simple fix: after readdir(d), in files.map(), filter for files; in other words, filter out directories.

The documentation seems to state that this should work:

directories: List[String] (Required: No, Default: [])
The directories input indicates which directories should be uploaded to Amazon S3. The action will recursively get all the files in said directories

...but I don't see how that could possibly be the case.

I can submit a PR if needed, but it seems like I have to be missing something here. Surely somebody would've tried to upload a directory tree >= 2 levels deep by now?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions