← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

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

 

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

Commit message:
some cleanup in SmbItemInfo::setInfo(), work around for directories is not necessary after fixing stat problem on device

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

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

some cleanup in SmbItemInfo::setInfo(), work around for directories is not necessary after fixing stat problem on device
-- 
Your team Ubuntu File Manager Developers is requested to review the proposed merge of lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-06 into lp:ubuntu-filemanager-app.
=== modified file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.cpp'
--- src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.cpp	2015-09-13 14:20:30 +0000
+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.cpp	2015-10-04 16:31:05 +0000
@@ -50,9 +50,8 @@
 void SmbItemInfo::setInfo(const QString& smb_path)
 {   
     SmbUtil *smb = const_cast<SmbUtil*> (m_smb);
-    //getStatInfo() is supposed to clear the struct stat unless the item does not exist
+    //getStatInfo() is supposed to clear the struct stat
     struct stat st;
-    ::memset(&st, 0, sizeof(struct stat));
     int ret  = smb->getStatInfo(smb_path, &st);
     //lets start with true
     d_ptr->_exists  = d_ptr->_isReadable = true;
@@ -64,16 +63,7 @@
          d_ptr->_isHost = false;
          d_ptr->_exists  = d_ptr->_isReadable = false;
          break;
-    case SmbUtil::StatDir:              
-        //if directories does not have permissions lets set default
-        //some smb stat functions does not work, this code will not hurt
-        if ((st.st_mode & S_IFMT) == 0)
-        {
-            st.st_mode |= S_IRUSR | S_IWUSR | S_IXUSR |
-                          S_IRGRP | S_IWGRP | S_IXGRP |
-                          S_IROTH | S_IXOTH;
-        }
-        st.st_mode |= S_IFDIR;
+    case SmbUtil::StatDir:                     
         break;
     case SmbUtil::StatHost:
         d_ptr->_isHost = true;

=== modified file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationitemfile.cpp'
--- src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationitemfile.cpp	2015-08-15 18:38:28 +0000
+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationitemfile.cpp	2015-10-04 16:31:05 +0000
@@ -232,13 +232,16 @@
     SmbUtil::StatReturn  ret  = SmbUtil::StatInvalid;
     if (isOpen())
     {       
-        ret = smbObj()->getFstat(m_context,m_fd, &st);
+        ret = static_cast<SmbUtil::StatReturn> (smbObj()->getFstat(m_context,m_fd,&st));
     }
     else
     {
-        SmbLocationItemFile *mySelf = const_cast<SmbLocationItemFile*> (this);
-        mySelf->createContext();
-        ret = smbObj()->getStat(m_context,cleanUrl(), &st);
+        if (m_context != 0) {
+            ret = static_cast<SmbUtil::StatReturn> (smbObj()->getStat(m_context,cleanUrl(),&st));
+        }
+        else {
+            ret = smbObj()->getStatInfo(cleanUrl(),&st);
+        }
     }
     if(ret == SmbUtil::StatDone)
     {

=== modified file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.cpp'
--- src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.cpp	2015-10-04 16:31:05 +0000
+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.cpp	2015-10-04 16:31:05 +0000
@@ -38,11 +38,17 @@
 
 #if defined(SHOW_MESSAGES)
 #  define DBG(more_items) qDebug() << Q_FUNC_INFO  more_items
+#  define DBG_STAT(ret) qDebug() << Q_FUNC_INFO \
+                                 << "return:" << ret \
+                                 << "mode:"   << st->st_mode \
+                                 << "mtime:"  << st->st_mtime \
+                                 << "size:"   << st->st_size
 #else
 #define DBG(none)
+#define DBG_STAT(ret)
 #endif
 
-#define SHOW_ERRNO(path)        if (errno != 0 && errno != ENOENT) \
+#define SHOW_ERRNO(path)        if (errno != 0) \
                                 { \
                                     qWarning() << Q_FUNC_INFO << "path:" << path << "errno:" << errno << strerror(errno); \
                                 }
@@ -358,7 +364,7 @@
     else if (errno != EACCES && errno != ECONNREFUSED) // perhaps is a file
     {
         errno = 0;
-        ret = getStat(context, smb_path,st);
+        ret = static_cast<SmbUtil::StatReturn> (getStat(context, smb_path,st));
     }
 
     if (errno != 0)
@@ -740,19 +746,22 @@
 }
 
 
-SmbUtil::StatReturn
+int
 SmbUtil::getFstat(Smb::Context context, Smb::FileHandler fd, struct stat*  st)
 {
      ::memset(st,0,sizeof(struct stat));
      int ret = ::smbc_getFunctionFstat(context)(context,fd, st);
-     return static_cast<SmbUtil::StatReturn> (ret);
+     DBG_STAT(ret);
+     return ret;
 }
 
 
-SmbUtil::StatReturn
+int
 SmbUtil::getStat(Smb::Context context, const QString& smb_path, struct stat*  st)
 {
     ::memset(st,0,sizeof(struct stat));
+    DBG(<< smb_path);
     int ret = ::smbc_getFunctionStat(context)(context,smb_path.toLocal8Bit().constData(), st);
-    return static_cast<SmbUtil::StatReturn> (ret);
+    DBG_STAT(ret);
+    return ret;
 }

=== modified file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.h'
--- src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.h	2015-07-15 13:00:56 +0000
+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.h	2015-10-04 16:31:05 +0000
@@ -94,8 +94,8 @@
                                  bool recursive = false,
                                  QDir::Filters filters = QDir::AllEntries | QDir::NoDotAndDotDot,
                                  const QStringList& filterNames = QStringList());
-    StatReturn       getFstat(Smb::Context context, Smb::FileHandler fd, struct stat*  st);
-    StatReturn       getStat(Smb::Context context, const QString& smb_path, struct stat*  st);
+    int              getFstat(Smb::Context context, Smb::FileHandler fd, struct stat*  st);
+    int              getStat(Smb::Context context, const QString& smb_path, struct stat*  st);
 
 private:   
     StatReturn      guessDirType(Smb::Context context, Smb::FileHandler fd);