From 84fe9debee920dc329298b3a319bc34a1e01b69b Mon Sep 17 00:00:00 2001 From: Nigel Jones Date: Fri, 6 Dec 2013 23:03:51 +1300 Subject: Revert "[nfs] - better fix for fe97d68f87d6985b2bf57d8e942b36b5e7373066 - possibly fixes #14727 - thx jm for the idea :)" This reverts commit dd4dd2e91bc083a23fe7b46ae4c291c6672d32e0. This commit created issues comparing paths when the export and the path was the same and did not contain a trailing slash, in addition, it removed the correct reversal of ordering of m_exportList generated by GetExportList. Reference: http://trac.xbmc.org/ticket/14727#comment:12 --- xbmc/filesystem/NFSFile.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xbmc/filesystem/NFSFile.cpp b/xbmc/filesystem/NFSFile.cpp index 3f04a34e69..7a54ab2250 100644 --- a/xbmc/filesystem/NFSFile.cpp +++ b/xbmc/filesystem/NFSFile.cpp @@ -95,11 +95,13 @@ std::list CNfsConnection::GetExportList(const CURL &url) for(tmp = exportlist; tmp!=NULL; tmp=tmp->ex_next) { std::string exportStr = std::string(tmp->ex_dir); - URIUtils::AddSlashAtEnd(exportStr); + retList.push_back(exportStr); } gNfsConnection.GetImpl()->mount_free_export_list(exportlist); + retList.sort(); + retList.reverse(); } return retList; @@ -260,9 +262,9 @@ bool CNfsConnection::splitUrlIntoExportAndPath(const CURL& url, CStdString &expo //in that case we don't want to stripp off to //much from the path if( exportPath == "/" ) - relativePath = "//" + path.substr(exportPath.length()-1); - else relativePath = "//" + path.substr(exportPath.length()); + else + relativePath = "//" + path.substr(exportPath.length()+1); ret = true; break; } -- cgit v1.2.3 From f6dd667309e35b78befc8fb0949dfcce5b323ee5 Mon Sep 17 00:00:00 2001 From: Nigel Jones Date: Mon, 9 Dec 2013 12:38:14 +1300 Subject: [nfs] Fix library syncing (trac #14727) for edge-cases resulting from less-common NFS export configurations partially resulting from recent CStdString conversion. Squashed commit of the following: commit 1cd13db9822a5a609c232a614e67c361ca260f2d Author: Nigel Jones Date: Sun Dec 8 02:47:08 2013 +1300 [nfs] Recommendation from PR 3772 by jmarshallnz for code cleanup implemented avoiding the substr routine. exportPath is only set if a valid export is found. commit be9d0b0aa42b4710a5005824c1d04f1a69120cbc Merge: a43d406 d32ff6e Author: Nigel Jones Date: Sat Dec 7 03:09:32 2013 -0800 Merge pull request #1 from Memphiz/nfsfix-14727 [nfs] - handle special case when "/" is exported via nfs - we need to al... commit d32ff6e89bde24909fbf7e97acf0bfa5a8ae5ac7 Author: Memphiz Date: Fri Dec 6 23:35:48 2013 +0100 [nfs] - handle special case when "/" is exported via nfs - we need to allow empty pathes here when accessing nfs://ip/ (path is empty here - export is "/"). commit a43d40673887965041939181dab8dcd077049c92 Author: Nigel Jones Date: Sat Dec 7 00:27:49 2013 +1300 [nfs] - Ensure that the right export is picked if multiple overlapping names may match with StartsWith. commit 61fb6f567f0a229c1869bbb76524706914574ba9 Author: Nigel Jones Date: Fri Dec 6 23:44:03 2013 +1300 [nfs] replacement fix for dd4dd2e91bc083a23fe7b46ae4c291c6672d32e0 (issue #14727). If the exportPath is the same as the path is then bypass the substr methods, and return the correct relativePath. --- xbmc/filesystem/NFSFile.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/xbmc/filesystem/NFSFile.cpp b/xbmc/filesystem/NFSFile.cpp index 7a54ab2250..be85265f7b 100644 --- a/xbmc/filesystem/NFSFile.cpp +++ b/xbmc/filesystem/NFSFile.cpp @@ -245,7 +245,7 @@ bool CNfsConnection::splitUrlIntoExportAndPath(const CURL& url, CStdString &expo //GetFileName returns path without leading "/" //but we need it because the export paths start with "/" //and path.Find(*it) wouldn't work else - if(!path.empty() && path[0] != '/') + if(path[0] != '/') { path = "/" + path; } @@ -257,11 +257,20 @@ bool CNfsConnection::splitUrlIntoExportAndPath(const CURL& url, CStdString &expo //if path starts with the current export path if(StringUtils::StartsWith(path, *it)) { + //its possible that StartsWith may not find the correct match first + //as an example, if /path/ & and /path/sub/ are exported, but + //the user specifies the path /path/subdir/ (from /path/ export). + //If the path is longer than the exportpath, make sure / is next. + if( (path.length() > (*it).length()) && + (path[(*it).length()] != '/') && (*it) != "/") + continue; exportPath = *it; //handle special case where root is exported //in that case we don't want to stripp off to //much from the path - if( exportPath == "/" ) + if( exportPath == path ) + relativePath = "//"; + else if( exportPath == "/" ) relativePath = "//" + path.substr(exportPath.length()); else relativePath = "//" + path.substr(exportPath.length()+1); -- cgit v1.2.3