chegele / AutoGitUpdate

Update node application from git repo.
65 stars 19 forks source link

Error: Cannot copy ... to a subdirectory of itself #6

Closed soylomass closed 3 years ago

soylomass commented 3 years ago

Hi, I'm getting the following error in production on a Centos machine

[10/21/2021, 6:23:13 PM] ERROR Auto Git Update - Error updating application [10/21/2021, 6:23:13 PM] ERROR Error: Cannot copy '../json5/lib/cli.js' to a subdirectory of itself, '../json5/lib/cli.js'. at /srv/manager/node_modules/auto-git-update/node_modules/fs-extra/lib/copy/copy.js:190:21 at FSReqCallback.oncomplete (fs.js:180:23)

The tmp path is a path outside the project ('/srv/tmp/')

chegele commented 3 years ago

Referencing https://github.com/jprichardson/node-fs-extra/issues/708, this seems to be a potential issue with the symbolic links that npm creates in the node_modules. I am not home to test this, but this can potentially be solved by adding the "dereference" option to the fs-extra copy options.

If you would like to test this solution yourself,

AutoGitUpdate/index.js on line 142 from

await fs.copy(appRootPath.path, destination);

TO

await fs.copy(appRootPath.path, destination, {dereference: true});
soylomass commented 3 years ago

@chegele Great, that fixed it.

Also, it seems that Github caches raw.githubusercontent for 5 minutes, and I'd like to run the update checker every minute. Have you found any way to bypass the cache?

chegele commented 3 years ago

@chegele Great, that fixed it.

Also, it seems that Github caches raw.githubusercontent for 5 minutes, and I'd like to run the update checker every minute. Have you found any way to bypass the cache?

I think that the cache is handled on the CDN server side, not on your local client. I do not believe there will be a way to bypass it.

This issue has been patched on the below versions

soylomass commented 3 years ago

@chegele I found a way to "bypass" it using the latest commit URL instead of just the branch URL. If it's a feature you'd like to add I can submit a pull request.

chegele commented 3 years ago

@chegele I found a way to "bypass" it using the latest commit URL instead of just the branch URL. If it's a feature you'd like to add I can submit a pull request.

For sure. If you could add it as an optional configuration that would be preferred. Feel free to open a separate issue if you would like to have more discussion on it.