Commit 5b678481 authored by Romain Courteaud's avatar Romain Courteaud

XXX [linshare] Test not using name property

parent b90df1a9
...@@ -133,11 +133,18 @@ ...@@ -133,11 +133,18 @@
i, i,
len = entry_list.length, len = entry_list.length,
entry_name, entry_name,
entry_metadata,
entry, entry,
result_list = []; result_list = [];
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
entry_name = entry_list[i].name; try {
entry_metadata = JSON.parse(entry_list[i].metaData) || {};
} catch (error) {
// Metadata are not always JSON
entry_metadata = {};
}
entry_name = entry_metadata.jio_id || entry_list[i].name;
// If we only need one precise name, no need to check the others // If we only need one precise name, no need to check the others
if (!options.hasOwnProperty('only_id') || if (!options.hasOwnProperty('only_id') ||
...@@ -150,7 +157,7 @@ ...@@ -150,7 +157,7 @@
_linshare_uuid: entry_list[i].uuid _linshare_uuid: entry_list[i].uuid
}; };
if (options.include_docs === true) { if (options.include_docs === true) {
entry.doc = JSON.parse(entry_list[i].metaData) || {}; entry.doc = entry_metadata.jio_metadata || {};
} }
result_list.push(entry); result_list.push(entry);
...@@ -201,9 +208,12 @@ ...@@ -201,9 +208,12 @@
var data = new FormData(); var data = new FormData();
data.append('file', blob, id); data.append('file', blob, id);
data.append('filesize', blob.size); data.append('filesize', blob.size);
data.append('filename', id); data.append('filename', doc.title || id);
data.append('description', doc.title || doc.description || ''); data.append('description', doc.description || id);
data.append('metadata', jIO.util.stringify(doc)); data.append('metadata', jIO.util.stringify({
jio_id: id,
jio_metadata: doc
}));
return makeRequest(storage, '', { return makeRequest(storage, '', {
type: 'POST', type: 'POST',
data: data data: data
...@@ -221,9 +231,12 @@ ...@@ -221,9 +231,12 @@
// Update existing document metadata // Update existing document metadata
var data = { var data = {
uuid: result_list[0]._linshare_uuid, uuid: result_list[0]._linshare_uuid,
metaData: jIO.util.stringify(doc), metaData: jIO.util.stringify({
name: id, jio_id: id,
description: doc.title || doc.description || '' jio_metadata: doc
}),
name: doc.title || id,
description: doc.description || id
}; };
return makeRequest(storage, result_list[0]._linshare_uuid, { return makeRequest(storage, result_list[0]._linshare_uuid, {
type: 'PUT', type: 'PUT',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment