Skip to content
This repository was archived by the owner on Jun 5, 2024. It is now read-only.

Commit 6d2a154

Browse files
committed
Remove getDirectoryAsZip() - uses non-public API
1 parent 713ed19 commit 6d2a154

File tree

4 files changed

+2
-76
lines changed

4 files changed

+2
-76
lines changed

owncloud/fileManagement.js

+1-28
Original file line numberDiff line numberDiff line change
@@ -204,33 +204,6 @@ files.prototype.getFile = function(path, localPath) {
204204
});
205205
};
206206

207-
/**
208-
* Downloads a remote directory as zip
209-
* @param {string} remotePath path of the folder at OC instance
210-
* @param {string} localPath path where to download
211-
* @returns {Promise.<status>} boolean: whether the operation was successful
212-
* @returns {Promise.<error>} string: error message, if any.
213-
*/
214-
files.prototype.getDirectoryAsZip = function(path, localPath) {
215-
path = helpers._normalizePath(path);
216-
localPath = localPath || __dirname + path;
217-
localPath = helpers._checkExtensionZip(localPath);
218-
path = helpers._encodeString(path);
219-
path = encodeURIComponent(path);
220-
path = path.split('%2F').join('/');
221-
222-
var url = helpers.instance + 'index.php/apps/files/ajax/download.php?dir=' + (path);
223-
224-
return new Promise((resolve, reject) => {
225-
helpers._writeData(url, localPath)
226-
.then(status => {
227-
resolve(status);
228-
}).catch(error => {
229-
reject(error);
230-
});
231-
});
232-
};
233-
234207
/**
235208
* Upload a file
236209
* @param {string} remotePath path of the file to be created at OC instance
@@ -252,7 +225,7 @@ files.prototype.putFile = function(path, localPath, keepMTime) {
252225
}
253226

254227
headers['Content-Length'] = helpers._getFileSize(localPath);
255-
headers.authorization = "Basic " + new Buffer(helpers._username + ":" + helpers._password).toString('base64');
228+
headers.authorization = helpers._authHeader;
256229

257230
return new Promise((resolve, reject) => {
258231
helpers._readFile(path, localPath, headers).then(status => {

owncloud/test/test.js

+1-28
Original file line numberDiff line numberDiff line change
@@ -1828,33 +1828,6 @@ describe("Currently testing files management,", function () {
18281828
});
18291829
});
18301830

1831-
it('checking method : getDirectoryAsZip for an existent folder', function (done) {
1832-
oc.files.getDirectoryAsZip(testFolder, downloadBasePath + timeRightNow +'.zip').then(status => {
1833-
expect(status).toBe(true);
1834-
1835-
fs.readFile(downloadBasePath + timeRightNow +'.zip', function(err, data) {
1836-
JSZip.loadAsync(data).then(function (zip) {
1837-
var count = Object.keys(zip.files).length;
1838-
expect(count).toEqual(7);
1839-
done();
1840-
});
1841-
});
1842-
}).catch(error => {
1843-
expect(error).toBe(null);
1844-
done();
1845-
});
1846-
});
1847-
1848-
it('checking method : getDirectoryAsZip for a non existent folder', function (done) {
1849-
oc.files.getDirectoryAsZip(testFolder + timeRightNow, downloadBasePath + timeRightNow +'.zip').then(status => {
1850-
expect(status).toBe(null);
1851-
done();
1852-
}).catch(error => {
1853-
expect(error).toBe('specified file/folder could not be located');
1854-
done();
1855-
});
1856-
});
1857-
18581831
it('checking method : putFile for an existent file', function (done) {
18591832
oc.files.putFile('/', localFile).then(status => {
18601833
expect(status).toBe(true);
@@ -1897,7 +1870,7 @@ describe("Currently testing files management,", function () {
18971870
expect(status).toBe(true);
18981871
return oc.files.list(testFolder + '/testDownloadDir', 'infinity');
18991872
}).then(files => {
1900-
expect(files.length).toEqual(5);
1873+
expect(files.length).toEqual(3);
19011874
done();
19021875
}).catch(error => {
19031876
expect(error).toBe(null);

owncloud/test/testUnauthenticated.js

-10
Original file line numberDiff line numberDiff line change
@@ -587,16 +587,6 @@ describe("Currently testing files management,", function() {
587587
});
588588
});
589589

590-
it('checking method : getDirectoryAsZip', function(done) {
591-
oc.files.getDirectoryAsZip(testFolder, downloadBasePath + timeRightNow + '.zip').then(status => {
592-
expect(status).toBe(null);
593-
done();
594-
}).catch(error => {
595-
expect(errors.indexOf(error)).toBeGreaterThan(-1);
596-
done();
597-
});
598-
});
599-
600590
it('checking method : putFile', function(done) {
601591
try {
602592
oc.files.putFile('/', localFile).then(status => {

owncloud/test/testUnauthorized.js

-10
Original file line numberDiff line numberDiff line change
@@ -602,16 +602,6 @@ describe("Currently testing files management,", function() {
602602
});
603603
});
604604

605-
it('checking method : getDirectoryAsZip', function(done) {
606-
oc.files.getDirectoryAsZip(testFolder, downloadBasePath + timeRightNow + '.zip').then(status => {
607-
expect(status).toBe(null);
608-
done();
609-
}).catch(error => {
610-
expect(errors.indexOf(error)).toBeGreaterThan(-1);
611-
done();
612-
});
613-
});
614-
615605
it('checking method : putFile', function(done) {
616606
try {
617607
oc.files.putFile('/', localFile).then(status => {

0 commit comments

Comments
 (0)