Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite FileSystemInfo #485

Open
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

ulmus-scott
Copy link
Contributor

This is inspired by #438 , in particular moving the various functions in mythcoreutil.h to more appropriately named files.

Checklist

@ulmus-scott
Copy link
Contributor Author

FileSystemInfo::refresh() now uses QStorageInfo.

FileSystemInfo::m_grpid is unused but part of the string lists.

Most if not all of the commits should be squashed before applying.

Also, for FileSystemInfo:
combine PopulateDiskSpace() and PopulateFSProp() into refresh() with comment from
getDiskSpace().

inline constructors and use compiler default copy assignment and copy constructor.

Add a shorter constructor to replace getDiskSpace().

Add doxygen comments.

Note: ZMServer::getDiskSpace() has been left as is, since zmserver is standard C++
only. i.e. does not use Qt.
Use for each loop.

The removed if statement is misleading, since the first directory could be empty,
and if all others are as well, it will be returned even though it is not usable.
I'm not sure what the existing comment was about, since MythTV never increases
m_used.
instead of duplicating its code.
add type alias FileSystemInfoList

FileServerHandler::QueryFileSystems():
 * QDir ignores (or will resolve) redunant separators to the same directory,
   so removing a trailing "/" is unnecessary.
 * The comment is from MainServer::BackendQueryDiskSpace() which duplicated the
   code (or vice versa).
in MainServer::BackendQueryDiskSpace()

The only difference with FileSystemInfo::Consolidate() was the use of
GetfsID() instead of starting from 0 every time.  I'm not sure why it
wasn't removed when the class was created in 65e877a.

The only change is that the m_fsid may not be the same for the same
hostname and path on subsequent calls to BackendQueryDiskSpace(),
which would be a wierd thing the rely on especially since this was the only
function that did that.
in MainServer::BackendQueryDiskSpace()
QList is a terrible container.  It is essentially a vector of pointers.

Use QVector instead, which should be the default Qt container.
based on namespace or class.
for getDiskSpace() removal and FileSystemInfo changes.
On Windows, QStorageInfo::device() appears to return either DOS device paths or
Universal Naming Convention (UNC) paths.  A DOS device path can use a UNC path,
which could escape the local system.
See https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats

For Unix-like systems, if the device file resides outside of /dev/, an alternate
boolean expression is:
device.startsWith("/") && (!device.startsWith("//") || device.startsWith("///"))

POSIX states:
A pathname that begins with two successive slashes may be interpreted in an
implementation-defined manner, although more than two leading slashes shall be
treated as a single slash.
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11

I saw a somewhat similar test for if the storage is local at
https://bugreports.qt.io/browse/QTBUG-83321
NB: if all hostnames are empty, which is already an error, the function
will incorrectly not generate the totals.
The header guards in mythbackend/filetransfer.h conflicted with those of
libmythprotoserver/sockethandler/filetransfer.h.
also remove unused EncoderLink::GetDiskSpace().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants