Windows: tree walk ends error if share discon. detected: no purge will be performed
This commit is contained in:
parent
85a3291fd7
commit
c1d593b104
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2004 J.F.Dockes
|
||||
/* Copyright (C) 2004-2019 J.F.Dockes
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
@ -52,8 +52,7 @@ public:
|
||||
dev_t dev;
|
||||
ino_t ino;
|
||||
DirId(dev_t d, ino_t i) : dev(d), ino(i) {}
|
||||
bool operator<(const DirId& r) const
|
||||
{
|
||||
bool operator<(const DirId& r) const {
|
||||
return dev < r.dev || (dev == r.dev && ino < r.ino);
|
||||
}
|
||||
};
|
||||
@ -362,7 +361,6 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top,
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
int curdepth = slashcount(top) - data->basedepth;
|
||||
if (data->maxdepth >= 0 && curdepth >= data->maxdepth) {
|
||||
LOGDEB1("FsTreeWalker::iwalk: Maxdepth reached: [" << (top) << "]\n" );
|
||||
@ -388,10 +386,21 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top,
|
||||
data->donedirs.insert(dirid);
|
||||
}
|
||||
#endif
|
||||
|
||||
SYSPATH(top, systop);
|
||||
DIRHDL *d = OPENDIR(systop);
|
||||
if (d == 0) {
|
||||
if (nullptr == d) {
|
||||
data->logsyserr("opendir", top);
|
||||
#ifdef _WIN32
|
||||
int rc = GetLastError();
|
||||
LOGERR("opendir failed: LastError " << rc << endl);
|
||||
if (rc == ERROR_NETNAME_DELETED) {
|
||||
// 64: share disconnected.
|
||||
// Not too sure of the errno in this case.
|
||||
// Make sure it's not one of the permissible ones
|
||||
errno = ENODEV;
|
||||
}
|
||||
#endif
|
||||
switch (errno) {
|
||||
case EPERM:
|
||||
case EACCES:
|
||||
@ -400,6 +409,7 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top,
|
||||
// We get this quite a lot, don't know why. To be checked.
|
||||
case EINVAL:
|
||||
#endif
|
||||
// No error set: indexing will continue in other directories
|
||||
goto out;
|
||||
default:
|
||||
status = FtwError;
|
||||
@ -408,7 +418,7 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top,
|
||||
}
|
||||
|
||||
struct DIRENT *ent;
|
||||
while ((ent = READDIR(d)) != 0) {
|
||||
while (errno = 0, ((ent = READDIR(d)) != 0)) {
|
||||
string fn;
|
||||
struct stat st;
|
||||
#ifdef _WIN32
|
||||
@ -437,6 +447,14 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top,
|
||||
int statret = path_fileprops(fn.c_str(), &st, data->options&FtwFollow);
|
||||
if (statret == -1) {
|
||||
data->logsyserr("stat", fn);
|
||||
#ifdef _WIN32
|
||||
int rc = GetLastError();
|
||||
LOGERR("stat failed: LastError " << rc << endl);
|
||||
if (rc == ERROR_NETNAME_DELETED) {
|
||||
status = FtwError;
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -493,6 +511,18 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top,
|
||||
}
|
||||
// We ignore other file types (devices etc...)
|
||||
} // readdir loop
|
||||
if (errno) {
|
||||
// Actual readdir error, not eof.
|
||||
data->logsyserr("readdir", top);
|
||||
#ifdef _WIN32
|
||||
int rc = GetLastError();
|
||||
LOGERR("Readdir failed: LastError " << rc << endl);
|
||||
if (rc == ERROR_NETNAME_DELETED) {
|
||||
status = FtwError;
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
out:
|
||||
if (d)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user