Commit d91436f6 authored by jayd1860's avatar jayd1860
Browse files

-- Fix setpaths error exception on linux and mac because ls([pathname, '*.m'])...

-- Fix setpaths error exception on linux and mac because ls([pathname, '*.m']) works differently on those platform than on Windows when there are NO files matching the specified pattern. Use dir instead of ls to fix this.
-- Fix multiple issues in submodule downloading using non-git method.
-- When user click cancel in response to download fail dialog, quit rather than retry.
-- Add search paths ONLY for the submodules that were successfully installed
-- Fix typos in dialog failed download message
parent f314a7bc
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@ s = parseGitSubmodulesFile();
% Check for missing libs
kk = checkMissingLibraries(s);
if isempty(kk) && optionExists_startup(options, 'init')
    addSearchPaths(s);
    return;
end

@@ -25,12 +24,11 @@ end
% Check again for missing libs
kk = checkMissingLibraries(s);
if isempty(kk) && (optionExists_startup(options, 'init') || all(errs==0))
    addSearchPaths(s);
    return;
end

% Try to install missing libs without git
branch = warningGitFailedToInstall(s);
branch = warningGitFailedToInstall(s(kk,:));
if ~isempty(branch)
    if optionExists_startup(options, 'init')
        downloadSubmodulesWithoutGit(s(kk,:), branch);
@@ -43,13 +41,12 @@ end
kk = checkMissingLibraries(s);
if isempty(kk)
    errs = 0;
    addSearchPaths(s);
    return;
end

q = warningManualInstallRequired(s(kk,:));
if q==1
    errs = -1;
    errs = -2;
else
    paths = searchFiles();
    if isempty(paths)
@@ -66,6 +63,8 @@ for ii = 1:size(s,1)
    if isIncompleteSubmodule(s{ii,3})
        removeFolderContents(s{ii,3});
        kk = [kk, ii]; %#ok<AGROW>
    else
        addSearchPaths(s(ii,:));
    end    
end

+39 −11
Original line number Diff line number Diff line
@@ -13,19 +13,47 @@ for ii = 1:size(submodules,1)
    [~, submodulename] = fileparts(url);
    filenameDownload = sprintf('./%s-%s', submodulename, branch);

    cleanup(filenameDownload);
    
    fprintf('Downloading %s/archive/refs/heads/%s.zip  to  %s\n', url, branch, [filenameDownload, '.zip']);
    urlwrite(sprintf('%s/archive/refs/heads/%s.zip', url, branch), [filenameDownload, '.zip']); %#ok<URLWR>

    install(filenameDownload, submodulepath);
    
    fprintf('\n');
end




% ----------------------------------------------------------
function cleanup(filenameDownload)
if ispathvalid_startup([filenameDownload, '.zip'])
    fprintf('Removing %s\n', [filenameDownload, '.zip']);
    try
        delete([filenameDownload, '.zip']);
    catch
        warning('Failed to remove %s\n', [filenameDownload, '.zip']);
    end
end
if ispathvalid_startup(filenameDownload)
    fprintf('Removing %s\n', filenameDownload);
    try
        rmdir(filenameDownload, 's');
    catch
        warning('Failed to remove %s\n', filenameDownload);
    end
end



% ---------------------------------------------------------
function install(filenameDownload, submodulepath)
if ispathvalid_startup([filenameDownload, '.zip'])
    fprintf('Unzipping %s\n', [filenameDownload, '.zip']);
    unzip([filenameDownload, '.zip']);
end
    
if ispathvalid_startup(filenameDownload)
    fprintf('Copying %s/*  to  %s\n', filenameDownload, submodulepath);
    copyfile([filenameDownload, '/*'], submodulepath);
end
    
    fprintf('\n');
end
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ b = false;
if ~ispathvalid_startup(folder, 'dir')
    return
end
if isempty(ls([folder,'/*.m']))
if isempty(dir([folder,'/*.m']))
    % Exceptions to rule that 'dotm' folder must have at least one '.m' file: 
    % it is a an executable folder (i.e. '/bin')
    if ~isempty(strfind(folder, '/bin/'))
+2 −2
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ addSearchPaths(appThisPaths);
% Download submodules
status = downloadLibraries(options);
if status<0
    fprintf('ERROR: Could no download shared libbraries required by this application...\n')
    fprintf('ERROR: Could not download shared libraries required by this application...\n')
    return;
end
setNamespace('Homer3');
@@ -121,7 +121,7 @@ nTries = 2;
h = waitbar(0,'Downloading shared libraries.');
for iTry = 1:nTries
    [cmds, errs, msgs] = downloadSharedLibs(options); %#ok<ASGLU>
    if all(errs==0)
    if all(errs==0 | errs == -2)
        break
    end
end