From be0543961df4d4f96be17e314d18888d40db8a22 Mon Sep 17 00:00:00 2001 From: Jan Lemmer <jan.lemmer@fst.tu-darmstadt.de> Date: Thu, 7 Oct 2021 14:42:47 +0200 Subject: [PATCH] fixes #38 --- +PlotID/Publish.m | 3 +-- +PlotID/createFileCopy.m | 21 ++++++++++++++++++--- +PlotID/fileCompare.m | 17 ----------------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/+PlotID/Publish.m b/+PlotID/Publish.m index 346dad0..6366dc8 100644 --- a/+PlotID/Publish.m +++ b/+PlotID/Publish.m @@ -128,8 +128,7 @@ switch options.Method fList.path = fullfile(fList.folder,fList.name); sourcePath = fList{idx,'path'}; relativeSourcePath = strrep(sourcePath,currentPath,''); - - %WIP relative PATh!! + if contains(sourcePath,{'.h5','.hdf5'}) % Linking only for HDF5 PlotID.createLinkedHDF5(relativeSourcePath{1,1},storPath,ID); end diff --git a/+PlotID/createFileCopy.m b/+PlotID/createFileCopy.m index 1945690..a6c8959 100644 --- a/+PlotID/createFileCopy.m +++ b/+PlotID/createFileCopy.m @@ -34,7 +34,6 @@ function [storagePaths] = createFileCopy(filePaths,folderName,storPath,ID,type) error([type,' is not a valid type for createFileCopy']) end %switch - % Write the file RemotePath = fullfile(storPath,folderName, newfile); % Check if remote file already exists @@ -50,8 +49,22 @@ function [storagePaths] = createFileCopy(filePaths,folderName,storPath,ID,type) else RemotePath = fullfile(storPath,folderName,... [name(1:end-length(num2str(count))),num2str(count),ext]); - end - warning('Filename already exists in data folder'); + end + [~, name, ~] = fileparts(RemotePath); + + + msg = ['Filename ',name,... + ' already exists in the data folder' newline,... + ' PlotID will add an suffix if you continue.' newline,... + ' This can cause serious confusions.']; + warning(msg); + m = input('Do you want to continue, Y/N [Y]:','s'); + + if ismember(m,{'N','n'}) + errorMSG = ['Filename already exists in data folder.' newline,... + ' Rename the File and restart PlotID.']; + error(); + end end copyfile(FileNameAndLocation,RemotePath); storagePaths{i} = RemotePath; @@ -59,6 +72,8 @@ function [storagePaths] = createFileCopy(filePaths,folderName,storPath,ID,type) disp([type, ' sucessfully published']); catch warning([type,' export was not sucessful']) + if exist('errorMSG') + error(errorMSG); end %try end diff --git a/+PlotID/fileCompare.m b/+PlotID/fileCompare.m index cbe1374..8317328 100644 --- a/+PlotID/fileCompare.m +++ b/+PlotID/fileCompare.m @@ -26,23 +26,6 @@ for i=1:height(fileList) filepath = fullfile(fileList{i,'folder'},fileList{i,'name'}); - - %% old - %crucial performance due to matlab bug - %(see https://de.mathworks.com/matlabcentral/answers/338553-performance-of-system-dos-function) -% if ispc -% filename = ['"',filename,'"'];% Bugfix for spaces in path -% status = comparejava -% % system call that causes performance issues -% [status,~] = system(['fc ' filename ' ' char(filepath)]); -% % 0 -> identical, 1 -> not identical -% status = ~status; % false (not identical), true(identical) -% -% elseif isunix %untested! -% [status,~] = system(['diff ' filename ' ' filepath]); -% else -% warning('Platform not supported') -% end %% comparison with java function % TODO test paths with spaces status = comparejava(filename, char(filepath)); -- GitLab