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
obj.msg = message;
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)
%userMSG user message without priority
% MSG will only be displaye if ShowMessages is true
......
......@@ -107,12 +107,23 @@ switch options.Location
end
folderName = ['.',char(ID)]; %hidden folder
folderNameV = char(ID); %visible Folder
%% Create data directory
overwriteDir = false;
% if invisible Folder exists, delete it (publish was not succesfull before)
if isfolder(fullfile(storPath,folderName))
dlgObj.error(['Folder ',folderName, ' exists - Plot was already published ']);
elseif mkdir(fullfile(storPath,folderName))
else
rmdir(fullfile(storPath,folderName),'s')
end
% 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');
end
disp(['publishing of ', ID, ' started']);
......@@ -239,9 +250,11 @@ end
if dlgObj.success || options.ForcePublish
oldPath = fullfile(storPath,folderName);
newPath = strrep(oldPath,'.',''); %remov dot
if overwriteDir
rmdir(newPath,'s');
dlgObj.userMSG(['old export ', folderNameV, ' deleted']);
end
status = movefile(oldPath,newPath); %rename directory
else
% error from userDlg class!
end
if status
......
......@@ -29,7 +29,8 @@ codegen/
# Personal test files
test*.m
test123_data.h5
test*.h5
cleanUP.m
# files that are created in example.m
......@@ -41,7 +42,6 @@ unused*/*
# Octave session info
octave-workspace
test_data.mat
#logs
log.txt
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment