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

Fix "EXDEV: cross-device link not permitted" error #1174

Merged
merged 3 commits into from
Feb 16, 2017
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"loader-utils": "0.2.16",
"minimist": "1.2.0",
"mkdirp-then": "1.2.0",
"mv": "^2.1.1",
"mz": "2.6.0",
"path-match": "1.2.4",
"pkg-up": "1.0.0",
Expand Down
11 changes: 8 additions & 3 deletions server/build/replace.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { rename } from 'mz/fs'
import mv from 'mv'
import { join } from 'path'

export default async function replaceCurrentBuild (dir, buildDir) {
Expand All @@ -7,10 +7,15 @@ export default async function replaceCurrentBuild (dir, buildDir) {
const oldDir = join(buildDir, '.next.old')

try {
await rename(_dir, oldDir)
await move(_dir, oldDir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mv package doesn't return a promise but rather expects a callback, in this case await will not wait for the move to complete.
https://github.com/andrewrk/node-mv/blob/master/index.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, mv doesn't return a promise so that's why I created the move wrapper function and used that. Await works as expected.

Copy link
Member

@timneutkens timneutkens Feb 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right 👍 Was reviewing on my phone

} catch (err) {
if (err.code !== 'ENOENT') throw err
}
await rename(_buildDir, _dir)
await move(_buildDir, _dir)
return oldDir
}

function move (from, to) {
return new Promise((resolve, reject) =>
mv(from, to, err => err ? reject(err) : resolve()))
}