| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 89a10df commit 29a9a82
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,7 +28,21 @@ Clone.clone = function(url, local_path, options) { | |||
| 28 | 28 | normalizeOptions(remoteCallbacks, NodeGit.RemoteCallbacks); | |
| 29 | 29 | } | |
| 30 | 30 | ||
| 31 | - return clone.call(this, url, local_path, options); | ||
| 31 | + // This is required to clean up after the clone to avoid file locking | ||
| 32 | + // issues in Windows and potentially other issues we don't know about. | ||
| 33 | + var freeRepository = function(repository) { | ||
| 34 | + repository.free(); | ||
| 35 | + }; | ||
| 36 | + | ||
| 37 | + // We want to provide a valid repository object, so reopen the repository | ||
| 38 | + // after clone and cleanup. | ||
| 39 | + var openRepository = function() { | ||
| 40 | + return NodeGit.Repository.open(local_path); | ||
| 41 | + }; | ||
| 42 | + | ||
| 43 | + return clone.call(this, url, local_path, options) | ||
| 44 | + .then(freeRepository) | ||
| 45 | + .then(openRepository); | ||
| 32 | 46 | }; | |
| 33 | 47 | ||
| 34 | 48 | module.exports = Clone; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,14 +47,6 @@ beforeEach(function() { | |||
| 47 | 47 | }); | |
| 48 | 48 | ||
| 49 | 49 | afterEach(function(done) { | |
| 50 | - // In Windows if you do not clean up the repository, there may become a | ||
| 51 | - // conflict with file locking. | ||
| 52 | - if (this.repository && process.platform === "win32") { | ||
| 53 | - this.repository.stateCleanup(); | ||
| 54 | - this.repository.free(); | ||
| 55 | - delete this.repository; | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | 50 | process.nextTick(function() { | |
| 59 | 51 | global.gc(); | |
| 60 | 52 | done(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,21 +17,6 @@ describe("Clone", function() { | |||
| 17 | 17 | // Set a reasonable timeout here now that our repository has grown. | |
| 18 | 18 | this.timeout(30000); | |
| 19 | 19 | ||
| 20 | - beforeEach(function(done) { | ||
| 21 | - // In Windows if you do not clean up the repository, there may become a | ||
| 22 | - // conflict with file locking. | ||
| 23 | - if (this.repository && process.platform === "win32") { | ||
| 24 | - this.repository.stateCleanup(); | ||
| 25 | - this.repository.free(); | ||
| 26 | - delete this.repository; | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | - process.nextTick(function() { | ||
| 30 | - global.gc(); | ||
| 31 | - done(); | ||
| 32 | - }); | ||
| 33 | - }); | ||
| 34 | - | ||
| 35 | 20 | beforeEach(function() { | |
| 36 | 21 | return fse.remove(clonePath).catch(function(err) { | |
| 37 | 22 | console.log(err); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments