Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/ndi/+ndi/+cloud/+upload/uploadDocumentCollection.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,31 @@
datasetId (1,1) string
documentList (1,:) cell
options.maxDocumentChunk (1,1) double = Inf
options.onlyUploadMissing (1,1) logical = true
end
assert(~isempty(documentList), 'List of documents was empty.')

% --- Pre-processing Step ---
if options.onlyUploadMissing
[success, remoteDocs] = ndi.cloud.api.documents.listDatasetDocumentsAll(datasetId);
if ~success
error('Could not list remote documents to determine which to upload.');
end
remoteDocIds = string(cellfun(@(x) x.id, remoteDocs.documents, 'UniformOutput', false));
localDocIds = string(cellfun(@(x) x.id(), documentList, 'UniformOutput', false));

[~, keepIndexes] = setdiff(localDocIds, remoteDocIds);
documentList = documentList(keepIndexes);
end

if isempty(documentList)
b = true;
report.uploadType = 'none';
report.manifest = {};
report.status = {};
return;
end

% Extract document IDs for the report manifest
docIds = cellfun(@(x) x.id(), documentList, 'UniformOutput', false);

Expand Down
Loading