Skip to content
Snippets Groups Projects
Commit e080002e authored by Lemmer, Jan's avatar Lemmer, Jan
Browse files

Solves Issues regarding multiple publishing

parent 4705d07a
No related branches found
No related tags found
2 merge requests!43Implements #73, cleans up example file,,!35Solves Issues regarding multiple publishing
Pipeline #592842 passed
...@@ -43,6 +43,20 @@ classdef userDLG ...@@ -43,6 +43,20 @@ classdef userDLG
obj.msg = message; obj.msg = message;
end end
function [status] = userDialog(obj,dialogMessage, errorMessage)
%userDialog displays Y/N user input
% if the user selects no an Error will be thrown
m = '';
while ~ismember(m,{'Y','y','n','N'})
m = input([dialogMessage,', Y/N [Y]? '],'s');
end
if ismember(m,{'Y','y'})
status = true;
else
obj.error(errorMessage)
end
end
function [] = userMSG(obj,message) function [] = userMSG(obj,message)
%userMSG user message without priority %userMSG user message without priority
% MSG will only be displaye if ShowMessages is true % MSG will only be displaye if ShowMessages is true
......
...@@ -107,12 +107,23 @@ switch options.Location ...@@ -107,12 +107,23 @@ switch options.Location
end end
folderName = ['.',char(ID)]; %hidden folder folderName = ['.',char(ID)]; %hidden folder
folderNameV = char(ID); %visible Folder
%% Create data directory %% Create data directory
overwriteDir = false;
% if invisible Folder exists, delete it (publish was not succesfull before)
if isfolder(fullfile(storPath,folderName)) if isfolder(fullfile(storPath,folderName))
dlgObj.error(['Folder ',folderName, ' exists - Plot was already published ']); rmdir(fullfile(storPath,folderName),'s')
elseif mkdir(fullfile(storPath,folderName)) end
else % if folder already published: ask User
if isfolder(fullfile(storPath,folderNameV))
msg = ['Folder ',folderNameV, ' exists - Plot was already published '];
disp(msg);
dialogMsg = 'Do you want to overwrite the existing files';
overwriteDir = dlgObj.userDialog(dialogMsg, msg);
end
% create folder
if ~mkdir(fullfile(storPath,folderName))
dlgObj.error('Directory could not be created - check remote path and permissions'); dlgObj.error('Directory could not be created - check remote path and permissions');
end end
disp(['publishing of ', ID, ' started']); disp(['publishing of ', ID, ' started']);
...@@ -239,9 +250,11 @@ end ...@@ -239,9 +250,11 @@ end
if dlgObj.success || options.ForcePublish if dlgObj.success || options.ForcePublish
oldPath = fullfile(storPath,folderName); oldPath = fullfile(storPath,folderName);
newPath = strrep(oldPath,'.',''); %remov dot newPath = strrep(oldPath,'.',''); %remov dot
if overwriteDir
rmdir(newPath,'s');
dlgObj.userMSG(['old export ', folderNameV, ' deleted']);
end
status = movefile(oldPath,newPath); %rename directory status = movefile(oldPath,newPath); %rename directory
else
% error from userDlg class!
end end
if status if status
......
...@@ -29,7 +29,8 @@ codegen/ ...@@ -29,7 +29,8 @@ codegen/
# Personal test files # Personal test files
test*.m test*.m
test123_data.h5 test*.h5
cleanUP.m
# files that are created in example.m # files that are created in example.m
...@@ -41,7 +42,6 @@ unused*/* ...@@ -41,7 +42,6 @@ unused*/*
# Octave session info # Octave session info
octave-workspace octave-workspace
test_data.mat
#logs #logs
log.txt log.txt
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment