Skip to content

Commit 570b903

Browse files
committed
Allow for individual files to be uploaded to a WebDAV remote server
1 parent f9462da commit 570b903

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/core/webdavconnection.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,9 @@ void WebdavConnection::downloadPath( const QString &localPath )
654654

655655
void WebdavConnection::uploadPath( const QString &localPath )
656656
{
657-
QDir dir( localPath );
657+
QFileInfo fi( QDir::cleanPath( localPath ) );
658+
QDir dir( fi.isFile() ? fi.absolutePath() : fi.absoluteFilePath() );
659+
658660
bool webdavConfigurationExists = dir.exists( "qfield_webdav_configuration.json" );
659661
QStringList remoteChildrenPath;
660662
while ( !webdavConfigurationExists )
@@ -683,20 +685,28 @@ void WebdavConnection::uploadPath( const QString &localPath )
683685
{
684686
mProcessRemotePath = mProcessRemotePath + remoteChildrenPath.join( "/" ) + QStringLiteral( "/" );
685687
}
686-
mProcessLocalPath = QDir::cleanPath( localPath ) + QDir::separator();
688+
689+
mProcessLocalPath = QDir::cleanPath( fi.isFile() ? fi.absolutePath() : fi.absoluteFilePath() ) + QDir::separator();
687690

688691
mWebdavLastModified.clear();
689692

690-
mLocalItems.clear();
691-
QDirIterator it( mProcessLocalPath, QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories );
692-
while ( it.hasNext() )
693+
if ( fi.isDir() )
693694
{
694-
it.next();
695-
if ( it.fileName() != QStringLiteral( "qfield_webdav_configuration.json" ) )
695+
mLocalItems.clear();
696+
QDirIterator it( mProcessLocalPath, QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories );
697+
while ( it.hasNext() )
696698
{
697-
mLocalItems << it.fileInfo();
699+
it.next();
700+
if ( it.fileName() != QStringLiteral( "qfield_webdav_configuration.json" ) )
701+
{
702+
mLocalItems << it.fileInfo();
703+
}
698704
}
699705
}
706+
else
707+
{
708+
mLocalItems << fi;
709+
}
700710

701711
mBytesProcessed = 0;
702712
mBytesTotal = 0;

0 commit comments

Comments
 (0)