mirror of
https://github.com/nzbget/nzbget.git
synced 2025-12-23 22:27:45 -05:00
#688: always using dirbrowser snapshot
to fix issues with leftovers on cleanup
This commit is contained in:
@@ -3,10 +3,6 @@
|
||||
/* Define to 1 to include debug-code */
|
||||
#undef DEBUG
|
||||
|
||||
/* Define to 1 if deleting of files during reading of directory is not
|
||||
properly supported by OS */
|
||||
#undef DIRBROWSER_SNAPSHOT
|
||||
|
||||
/* Define to 1 to not use curses */
|
||||
#undef DISABLE_CURSES
|
||||
|
||||
|
||||
14
configure
vendored
14
configure
vendored
@@ -6611,20 +6611,6 @@ _ACEOF
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether dir-browser snapshot workaround is needed" >&5
|
||||
$as_echo_n "checking whether dir-browser snapshot workaround is needed... " >&6; }
|
||||
if test "$target_vendor" == "apple"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
|
||||
$as_echo "#define DIRBROWSER_SNAPSHOT 1" >>confdefs.h
|
||||
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cpu cores via sysconf" >&5
|
||||
$as_echo_n "checking for cpu cores via sysconf... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
|
||||
12
configure.ac
12
configure.ac
@@ -222,18 +222,6 @@ AC_TRY_COMPILE([
|
||||
AC_DEFINE_UNQUOTED(SOCKLEN_T, $SOCKLEN_T, [Determine what socket length (socklen_t) data type is])
|
||||
|
||||
|
||||
dnl
|
||||
dnl Dir-browser's snapshot
|
||||
dnl
|
||||
AC_MSG_CHECKING(whether dir-browser snapshot workaround is needed)
|
||||
if test "$target_vendor" == "apple"; then
|
||||
AC_MSG_RESULT([[yes]])
|
||||
AC_DEFINE([DIRBROWSER_SNAPSHOT], 1, [Define to 1 if deleting of files during reading of directory is not properly supported by OS])
|
||||
else
|
||||
AC_MSG_RESULT([[no]])
|
||||
fi
|
||||
|
||||
|
||||
dnl
|
||||
dnl check cpu cores via sysconf
|
||||
dnl
|
||||
|
||||
@@ -1020,52 +1020,9 @@ CString FileSystem::WidePathToUtfPath(const wchar_t* wpath)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
DirBrowser::DirBrowser(const char* path)
|
||||
{
|
||||
BString<1024> mask("%s%c*.*", path, PATH_SEPARATOR);
|
||||
m_file = FindFirstFileW(FileSystem::UtfPathToWidePath(mask), &m_findData);
|
||||
m_first = true;
|
||||
}
|
||||
|
||||
DirBrowser::~DirBrowser()
|
||||
{
|
||||
if (m_file != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
FindClose(m_file);
|
||||
}
|
||||
}
|
||||
|
||||
const char* DirBrowser::InternNext()
|
||||
{
|
||||
bool ok = false;
|
||||
if (m_first)
|
||||
{
|
||||
ok = m_file != INVALID_HANDLE_VALUE;
|
||||
m_first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ok = FindNextFileW(m_file, &m_findData) != 0;
|
||||
}
|
||||
if (ok)
|
||||
{
|
||||
m_filename = FileSystem::WidePathToUtfPath(m_findData.cFileName);
|
||||
return m_filename;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#ifdef DIRBROWSER_SNAPSHOT
|
||||
DirBrowser::DirBrowser(const char* path, bool snapshot) :
|
||||
m_snapshot(snapshot)
|
||||
#else
|
||||
DirBrowser::DirBrowser(const char* path)
|
||||
#endif
|
||||
{
|
||||
#ifdef DIRBROWSER_SNAPSHOT
|
||||
if (m_snapshot)
|
||||
{
|
||||
DirBrowser dir(path, false);
|
||||
@@ -1076,35 +1033,57 @@ DirBrowser::DirBrowser(const char* path)
|
||||
m_snapshotIter = m_snapshotFiles.begin();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef WIN32
|
||||
BString<1024> mask("%s%c*.*", path, PATH_SEPARATOR);
|
||||
m_file = FindFirstFileW(FileSystem::UtfPathToWidePath(mask), &m_findData);
|
||||
m_first = true;
|
||||
#else
|
||||
m_dir = opendir(path);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
DirBrowser::~DirBrowser()
|
||||
{
|
||||
#ifdef DIRBROWSER_SNAPSHOT
|
||||
if (!m_snapshot)
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
if (m_file != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (m_dir)
|
||||
{
|
||||
closedir(m_dir);
|
||||
}
|
||||
FindClose(m_file);
|
||||
}
|
||||
#else
|
||||
if (m_dir)
|
||||
{
|
||||
closedir(m_dir);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
const char* DirBrowser::InternNext()
|
||||
{
|
||||
#ifdef DIRBROWSER_SNAPSHOT
|
||||
if (m_snapshot)
|
||||
{
|
||||
return m_snapshotIter == m_snapshotFiles.end() ? nullptr : **m_snapshotIter++;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef WIN32
|
||||
bool ok = false;
|
||||
if (m_first)
|
||||
{
|
||||
ok = m_file != INVALID_HANDLE_VALUE;
|
||||
m_first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ok = FindNextFileW(m_file, &m_findData) != 0;
|
||||
}
|
||||
if (ok)
|
||||
{
|
||||
m_filename = FileSystem::WidePathToUtfPath(m_findData.cFileName);
|
||||
return m_filename;
|
||||
}
|
||||
#else
|
||||
if (m_dir)
|
||||
{
|
||||
m_findData = readdir(m_dir);
|
||||
@@ -1113,10 +1092,10 @@ const char* DirBrowser::InternNext()
|
||||
return m_findData->d_name;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
const char* DirBrowser::Next()
|
||||
{
|
||||
|
||||
@@ -84,11 +84,7 @@ public:
|
||||
class DirBrowser
|
||||
{
|
||||
public:
|
||||
#ifdef DIRBROWSER_SNAPSHOT
|
||||
DirBrowser(const char* path, bool snapshot = true);
|
||||
#else
|
||||
DirBrowser(const char* path);
|
||||
#endif
|
||||
~DirBrowser();
|
||||
const char* Next();
|
||||
|
||||
@@ -103,12 +99,10 @@ private:
|
||||
struct dirent* m_findData;
|
||||
#endif
|
||||
|
||||
#ifdef DIRBROWSER_SNAPSHOT
|
||||
bool m_snapshot;
|
||||
typedef std::deque<CString> FileList;
|
||||
FileList m_snapshotFiles;
|
||||
FileList::iterator m_snapshotIter;
|
||||
#endif
|
||||
|
||||
const char* InternNext();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user