Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/badges/code_issues.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions code/+nansen/+config/+addons/@AddonManager/AddonManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,9 @@ function checkIfAddonsAreOnPath()

% Rename folder to remove main/master tag
renamedDir = fullfile(rootDir, newName);
if isfolder(renamedDir)
rmdir(renamedDir, 's')
end
movefile(newDir, renamedDir)
folderPath = renamedDir;
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function configureLocalRootPath(obj, localRootPath, originalRootPath)
% name of the disk and the current letter assignment.

if ispc
volumeInfo = nansen.external.fex.sysutil.listPhysicalDrives();
volumeInfo = nansen.external.fex.sysutil.listMountedDrives();

for i = 1:numel(data) % Loop through DataLocations
if ~isfield(data(i), 'RootPath')
Expand Down Expand Up @@ -245,7 +245,7 @@ function updateVolumeInfo(obj, volumeInfo)
% updateVolumeInfo(obj) updates volume info using system utilities.
% updateVolumeInfo(obj, volumeInfo) uses the provided volume info.

import nansen.external.fex.sysutil.listPhysicalDrives
import nansen.external.fex.sysutil.listMountedDrives
if nargin < 2
volumeInfo = listPhysicalDrives();
end
Expand Down
16 changes: 10 additions & 6 deletions code/+nansen/+dataio/+dialog/editDataLocationRootDeviceName.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
% [ ] Is it possible to indicate that the diskname is a dropdown?
% [ ] Update dropdowns if drives are connected or disconnected

if isunix && ~ismac
errordlg('This feature is not implemented for linux/unix systems')
return
try
volumeInfo = nansen.external.fex.sysutil.listMountedDrives();
catch MECause
ME = MException('NANSEN:DataIO:FailedToListDrives', ...
['Failed to list mounted drives using system command. ' ...
'Please report if you see this error.']);
ME = ME.addCause(MECause);
errordlg('Failed to list mounted drives using system command. See MATLAB''s command window for details.')
throw(ME)
end

volumeInfo = nansen.external.fex.sysutil.listPhysicalDrives();


if ~isfield(dataLocationRootInfo, 'DiskType')
[dataLocationRootInfo(:).DiskType] = deal('External');
end
Expand Down
50 changes: 44 additions & 6 deletions code/+nansen/+internal/+system/DiskConnectionMonitor.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
classdef DiskConnectionMonitor < handle

% Todo
% - Streamline getting drive info from nansen.external.fex.sysutil.listMountedDrives
% - Create event data?
% - Use drive instead of disk in class/method/event names

properties (Dependent)
TimerUpdateInterval
end
Expand All @@ -22,11 +27,15 @@
methods

function obj = DiskConnectionMonitor
if ismac || ispc
obj.initializeTimer()
else
% pass (not implemented for linux)

if ispc || (isunix && ~ismac)
if ~obj.checkListDrivesWorks()
obj.displayListDrivesNotWorkingWarning()
return
end
end

obj.initializeTimer()
end

function delete(obj)
Expand Down Expand Up @@ -106,7 +115,7 @@ function updateDiskList(obj, updatedVolumeList)

function checkDiskPc(obj)
%volumeList = system.
volumeInfoTable = nansen.external.fex.sysutil.listPhysicalDrives();
volumeInfoTable = nansen.external.fex.sysutil.listMountedDrives();

% Convert string array to cell array of character vectors in
% order to create struct array below
Expand All @@ -130,7 +139,36 @@ function checkDiskMac(obj)
end

function checkDiskUnix(obj)
error('Not implemented yet')
volumeInfoTable = nansen.external.fex.sysutil.listMountedDrives();

% Convert string array to cell array of character vectors in
% order to create struct array below
string2cellchar = @(strArray) arrayfun(@char, strArray, 'uni', false); %convertStringsToChars, cellstr
volumeList = struct('Name', string2cellchar(volumeInfoTable.VolumeName) );

obj.updateDiskList(volumeList)
end

function tf = checkListDrivesWorks(~)
persistent listDrivesWorks
if isempty(listDrivesWorks)
try
nansen.external.fex.sysutil.listMountedDrives()
listDrivesWorks = true;
catch
listDrivesWorks = false;
end
end
tf = listDrivesWorks;
end

function displayListDrivesNotWorkingWarning(~)
nansen.common.tracelesswarning(sprintf([...
'Failed to list mounted drives using system command.\nIf you ', ...
'want NANSEN to dynamically update when drives are ', ...
'connected/disconnected, please run ', ...
'`nansen.external.fex.sysutil.listMountedDrives` and ', ...
'report the error you are seeing.']))
end
end

Expand Down
Loading