Skip to content

Instantly share code, notes, and snippets.

@nlaplante
nlaplante / gist:6617953
Last active December 23, 2015 09:59
node.js implementation to move files avoiding EXDEV errors when moving files across different devices
'use strict';
var fs = require('fs'),
q = require('q');
/**
* Move a file from src to dest, avoiding cross-device rename failures.
* This method will first try fs.rename and call the supplied callback if it succeeds. Otherwise
* it will pump the conent of src into dest and unlink src upon completion.
*