Discovery: Fix detection of hidden files.

In the discovery phase we want to detect that dot-files are hidden
on Linux and Mac.

This fixes strange behaviour seen in issue #3980
This commit is contained in:
Klaas Freitag 2015-10-26 14:24:05 +01:00
parent b5390b5aa2
commit 6b71273380
2 changed files with 19 additions and 3 deletions

View file

@ -688,8 +688,8 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
}
/* skip "." and ".." */
if (d_name[0] == '.' && (d_name[1] == '\0'
|| (d_name[1] == '.' && d_name[2] == '\0'))) {
if ( (d_name[0] == '.' && d_name[1] == '\0')
|| (d_name[0] == '.' && d_name[1] == '.' && d_name[2] == '\0')) {
csync_vio_file_stat_destroy(dirent);
dirent = NULL;
continue;
@ -748,6 +748,16 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
res = 0;
}
/* for non windows platforms, detect if the filename starts with a .
* and if so, it's a hidden file. For windows, the hidden state is
* discovered within the vio local stat function.
*/
#ifndef _WIN32
if( d_name[0] == '.' ) {
fs->flags |= CSYNC_VIO_FILE_FLAGS_HIDDEN;
}
#endif
if( res == 0) {
switch (fs->type) {
case CSYNC_VIO_FILE_TYPE_SYMBOLIC_LINK:

View file

@ -317,7 +317,13 @@ void DiscoverySingleDirectoryJob::directoryListingIteratedSlot(QString file,QMap
if (!file_stat->etag || strlen(file_stat->etag) == 0) {
qDebug() << "WARNING: etag of" << file_stat->name << "is" << file_stat->etag << " This must not happen.";
}
if( file.startsWith(QChar('.')) ) {
QStringRef fileRef(&file);
int slashPos = file.lastIndexOf(QLatin1Char('/'));
if( slashPos > -1 ) {
fileRef = fileRef.mid(slashPos+1);
}
if( fileRef.startsWith(QChar('.')) ) {
file_stat->flags = CSYNC_VIO_FILE_FLAGS_HIDDEN;
}
//qDebug() << "!!!!" << file_stat << file_stat->name << file_stat->file_id << map.count();