← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-03 into lp:ubuntu-filemanager-app

 

Carlos Jose Mazieri has proposed merging lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-03 into lp:ubuntu-filemanager-app with lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-02 as a prerequisite.

Commit message:
Improved SmbUtil::getStatInfo() to not always open Directories and Files, Directories are always attempted but Files are not necessary, Files are tried just attempted with SmbUtil:getStat().

Requested reviews:
  Ubuntu File Manager Developers (ubuntu-filemanager-dev)

For more details, see:
https://code.launchpad.net/~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-03/+merge/273335

Improved SmbUtil::getStatInfo() to not always open Directories and Files, Directories are always attempted but Files are not necessary, Files are tried just attempted with SmbUtil:getStat().
-- 
Your team Ubuntu File Manager Developers is requested to review the proposed merge of lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-03 into lp:ubuntu-filemanager-app.
=== modified file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.cpp'
--- src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.cpp	2015-08-15 17:47:55 +0000
+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.cpp	2015-10-04 15:47:50 +0000
@@ -340,45 +340,28 @@
     StatReturn ret = StatInvalid;
     int slashes = smb_path.count(QDir::separator());
     Smb::FileHandler fd = 0;
-    //  smb:// -> slahes=2   smb://workgroup -> slahes=2   smb://host/share -> slashes=3=URL_SLASHES_NUMBER_FOR_SHARES
-    if ((fd=openDir(context, smb_path)))
-    {       
-        if ((ret = guessDirType(context,fd)) == StatDir && slashes == URL_SLASHES_NUMBER_FOR_SHARES)
-        {
-            ret  = StatShare;
-        }
-        if (slashes >= URL_SLASHES_NUMBER_FOR_SHARES  && (ret == StatShare || ret == StatDir))
-        {
-          /* smbc_getFunctionFstatdir does not work
-            ret = static_cast<StatReturn>(::smbc_getFunctionFstatdir(context)(context,fd, st));
-          */
-            QString ipUrl = NetUtil::urlConvertHostnameToIP(smb_path);
-            if (ipUrl.isEmpty())
+    ::memset(st, 0, sizeof(struct stat));
+    if ((fd=openDir(context, smb_path)) )
+        {
+        ret = guessDirType(context,fd);
+        closeHandle(context, fd);
+        if (ret == StatDir)
+        {
+            //  smb:// -> slahes=2   smb://workgroup -> slahes=2   smb://host/share -> slashes=3=URL_SLASHES_NUMBER_FOR_SHARES
+            if (slashes == URL_SLASHES_NUMBER_FOR_SHARES)
             {
-                ipUrl = smb_path;
+                ret = StatShare;
             }
-            (void)getStat(context,ipUrl, st);
+            (void)getStat(context,smb_path,st);
         }
     }
-    else
-    {
-        // there is no indication of what the item is,  directory or file
-        // if openDir() failed it may be a file, try openFile()
-        // do not try openFile() when: EACCES means it needs authentication, ECONNREFUSED means path does not exist
-        if (errno != EACCES && errno != ECONNREFUSED )
-        {
-            if ((fd = openFile(context,smb_path)))
+    else if (errno != EACCES && errno != ECONNREFUSED) // perhaps is a file
             {
-                ret =  getFstat(context,fd, st);
-            }
-        }
+        errno = 0;
+        ret = getStat(context, smb_path,st);
     }
 
-    if (fd)
-    {
-        closeHandle(context, fd);
-    }
-    else
+    if (errno != 0)
     {
         SHOW_ERRNO(smb_path);
         switch(errno)


Follow ups