| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 69b010a commit d5ad62c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ var shallowClone = NodeGit.Utils.shallowClone; | |||
| 8 | 8 | var Remote = NodeGit.Remote; | |
| 9 | 9 | var _connect = Remote.prototype.connect; | |
| 10 | 10 | var _createWithOpts = Remote.createWithOpts; | |
| 11 | + var _disconnect = Remote.prototype.disconnect; | ||
| 11 | 12 | var _download = Remote.prototype.download; | |
| 12 | 13 | var _fetch = Remote.prototype.fetch; | |
| 13 | 14 | var _push = Remote.prototype.push; | |
@@ -45,14 +46,60 @@ Remote.prototype.connect = function( | |||
| 45 | 46 | proxyOpts = normalizeOptions(proxyOpts || {}, NodeGit.ProxyOptions); | |
| 46 | 47 | customHeaders = customHeaders || []; | |
| 47 | 48 | ||
| 48 | - return _connect.call(this, direction, callbacks, proxyOpts, customHeaders); | ||
| 49 | + return _connect.call(this, direction, callbacks, proxyOpts, customHeaders) | ||
| 50 | + .then(() => { | ||
| 51 | + // Save options on the remote object. If we don't do this, | ||
| 52 | + // the options may be cleaned up and cause a segfault | ||
| 53 | + // when Remote.prototype.connect is called. | ||
| 54 | + Object.defineProperties(this, { | ||
| 55 | + callbacks: { | ||
| 56 | + configurable: true, | ||
| 57 | + value: callbacks, | ||
| 58 | + writable: false | ||
| 59 | + }, | ||
| 60 | + proxyOpts: { | ||
| 61 | + configurable: true, | ||
| 62 | + value: proxyOpts, | ||
| 63 | + writable: false | ||
| 64 | + }, | ||
| 65 | + customHeaders: { | ||
| 66 | + configurable: true, | ||
| 67 | + value: customHeaders, | ||
| 68 | + writable: false | ||
| 69 | + } | ||
| 70 | + }); | ||
| 71 | + }); | ||
| 49 | 72 | }; | |
| 50 | 73 | ||
| 51 | 74 | Remote.createWithOpts = function(url, options) { | |
| 52 | 75 | return _createWithOpts(url, normalizeOptions( | |
| 53 | 76 | options, NodeGit.RemoteCreateOptions)); | |
| 54 | 77 | }; | |
| 55 | 78 | ||
| 79 | + Remote.prototype.disconnect = function() { | ||
| 80 | + return _disconnect.call(this) | ||
| 81 | + .then(() => { | ||
| 82 | + // Release the options | ||
| 83 | + Object.defineProperties(this, { | ||
| 84 | + callbacks: { | ||
| 85 | + configurable: true, | ||
| 86 | + value: undefined, | ||
| 87 | + writable: false | ||
| 88 | + }, | ||
| 89 | + proxyOpts: { | ||
| 90 | + configurable: true, | ||
| 91 | + value: undefined, | ||
| 92 | + writable: false | ||
| 93 | + }, | ||
| 94 | + customHeaders: { | ||
| 95 | + configurable: true, | ||
| 96 | + value: undefined, | ||
| 97 | + writable: false | ||
| 98 | + } | ||
| 99 | + }); | ||
| 100 | + }); | ||
| 101 | + }; | ||
| 102 | + | ||
| 56 | 103 | /** | |
| 57 | 104 | * Connects to a remote | |
| 58 | 105 | * | |
| Back | FazBrowse Home | New Git URL |
0 commit comments