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

Proposed by Carlos Jose Mazieri on 2015-10-27
Status: Merged
Approved by: Arto Jalkanen on 2015-10-27
Approved revision: 479
Merged at revision: 490
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-06
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-05
Diff against target: 131 lines (+26/-24)
4 files modified
src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.cpp (+2/-12)
src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationitemfile.cpp (+7/-4)
src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.cpp (+15/-6)
src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.h (+2/-2)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-06
Reviewer Review Type Date Requested Status
Arto Jalkanen 2015-10-27 Approve on 2015-10-27
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve on 2015-10-27
Jenkins Bot continuous-integration Needs Fixing on 2015-10-27
Review via email: mp+275831@code.launchpad.net

Commit message

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

Description of the change

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

To post a comment you must log in.
review: Needs Fixing (continuous-integration)
review: Approve (continuous-integration)
Arto Jalkanen (ajalkane) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.cpp'
2--- src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.cpp 2015-09-13 14:20:30 +0000
3+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.cpp 2015-10-27 11:06:41 +0000
4@@ -50,9 +50,8 @@
5 void SmbItemInfo::setInfo(const QString& smb_path)
6 {
7 SmbUtil *smb = const_cast<SmbUtil*> (m_smb);
8- //getStatInfo() is supposed to clear the struct stat unless the item does not exist
9+ //getStatInfo() is supposed to clear the struct stat
10 struct stat st;
11- ::memset(&st, 0, sizeof(struct stat));
12 int ret = smb->getStatInfo(smb_path, &st);
13 //lets start with true
14 d_ptr->_exists = d_ptr->_isReadable = true;
15@@ -64,16 +63,7 @@
16 d_ptr->_isHost = false;
17 d_ptr->_exists = d_ptr->_isReadable = false;
18 break;
19- case SmbUtil::StatDir:
20- //if directories does not have permissions lets set default
21- //some smb stat functions does not work, this code will not hurt
22- if ((st.st_mode & S_IFMT) == 0)
23- {
24- st.st_mode |= S_IRUSR | S_IWUSR | S_IXUSR |
25- S_IRGRP | S_IWGRP | S_IXGRP |
26- S_IROTH | S_IXOTH;
27- }
28- st.st_mode |= S_IFDIR;
29+ case SmbUtil::StatDir:
30 break;
31 case SmbUtil::StatHost:
32 d_ptr->_isHost = true;
33
34=== modified file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationitemfile.cpp'
35--- src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationitemfile.cpp 2015-08-15 18:38:28 +0000
36+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationitemfile.cpp 2015-10-27 11:06:41 +0000
37@@ -232,13 +232,16 @@
38 SmbUtil::StatReturn ret = SmbUtil::StatInvalid;
39 if (isOpen())
40 {
41- ret = smbObj()->getFstat(m_context,m_fd, &st);
42+ ret = static_cast<SmbUtil::StatReturn> (smbObj()->getFstat(m_context,m_fd,&st));
43 }
44 else
45 {
46- SmbLocationItemFile *mySelf = const_cast<SmbLocationItemFile*> (this);
47- mySelf->createContext();
48- ret = smbObj()->getStat(m_context,cleanUrl(), &st);
49+ if (m_context != 0) {
50+ ret = static_cast<SmbUtil::StatReturn> (smbObj()->getStat(m_context,cleanUrl(),&st));
51+ }
52+ else {
53+ ret = smbObj()->getStatInfo(cleanUrl(),&st);
54+ }
55 }
56 if(ret == SmbUtil::StatDone)
57 {
58
59=== modified file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.cpp'
60--- src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.cpp 2015-10-27 11:06:41 +0000
61+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.cpp 2015-10-27 11:06:41 +0000
62@@ -38,11 +38,17 @@
63
64 #if defined(SHOW_MESSAGES)
65 # define DBG(more_items) qDebug() << Q_FUNC_INFO more_items
66+# define DBG_STAT(ret) qDebug() << Q_FUNC_INFO \
67+ << "return:" << ret \
68+ << "mode:" << st->st_mode \
69+ << "mtime:" << st->st_mtime \
70+ << "size:" << st->st_size
71 #else
72 #define DBG(none)
73+#define DBG_STAT(ret)
74 #endif
75
76-#define SHOW_ERRNO(path) if (errno != 0 && errno != ENOENT) \
77+#define SHOW_ERRNO(path) if (errno != 0) \
78 { \
79 qWarning() << Q_FUNC_INFO << "path:" << path << "errno:" << errno << strerror(errno); \
80 }
81@@ -358,7 +364,7 @@
82 else if (errno != EACCES && errno != ECONNREFUSED) // perhaps is a file
83 {
84 errno = 0;
85- ret = getStat(context, smb_path,st);
86+ ret = static_cast<SmbUtil::StatReturn> (getStat(context, smb_path,st));
87 }
88
89 if (errno != 0)
90@@ -740,19 +746,22 @@
91 }
92
93
94-SmbUtil::StatReturn
95+int
96 SmbUtil::getFstat(Smb::Context context, Smb::FileHandler fd, struct stat* st)
97 {
98 ::memset(st,0,sizeof(struct stat));
99 int ret = ::smbc_getFunctionFstat(context)(context,fd, st);
100- return static_cast<SmbUtil::StatReturn> (ret);
101+ DBG_STAT(ret);
102+ return ret;
103 }
104
105
106-SmbUtil::StatReturn
107+int
108 SmbUtil::getStat(Smb::Context context, const QString& smb_path, struct stat* st)
109 {
110 ::memset(st,0,sizeof(struct stat));
111+ DBG(<< smb_path);
112 int ret = ::smbc_getFunctionStat(context)(context,smb_path.toLocal8Bit().constData(), st);
113- return static_cast<SmbUtil::StatReturn> (ret);
114+ DBG_STAT(ret);
115+ return ret;
116 }
117
118=== modified file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.h'
119--- src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.h 2015-07-15 13:00:56 +0000
120+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smbutil.h 2015-10-27 11:06:41 +0000
121@@ -94,8 +94,8 @@
122 bool recursive = false,
123 QDir::Filters filters = QDir::AllEntries | QDir::NoDotAndDotDot,
124 const QStringList& filterNames = QStringList());
125- StatReturn getFstat(Smb::Context context, Smb::FileHandler fd, struct stat* st);
126- StatReturn getStat(Smb::Context context, const QString& smb_path, struct stat* st);
127+ int getFstat(Smb::Context context, Smb::FileHandler fd, struct stat* st);
128+ int getStat(Smb::Context context, const QString& smb_path, struct stat* st);
129
130 private:
131 StatReturn guessDirType(Smb::Context context, Smb::FileHandler fd);

Subscribers

People subscribed via source and target branches