[Sugar-devel] [PATCH sugar] Only show DOCUMENTS folder when it is not $HOME
'xdg-user-dir DOCUMENTS' will return $HOME when DOCUMENTS does not exist, only display the DOCUMENTS folder when the actual folder exists Signed-off-by: Simon Schampijer --- src/jarabe/journal/volumestoolbar.py |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py index 84d9e31..3aa37da 100644 --- a/src/jarabe/journal/volumestoolbar.py +++ b/src/jarabe/journal/volumestoolbar.py @@ -68,7 +68,8 @@ def _get_documents_path(): pipe = subprocess.Popen(['xdg-user-dir', 'DOCUMENTS'], stdout=subprocess.PIPE) documents_path = pipe.communicate()[0].strip() -if os.path.exists(documents_path): +if os.path.exists(documents_path) and \ +os.environ.get('HOME') + '/' != documents_path: return documents_path except OSError, exception: if exception.errno != errno.ENOENT: -- 1.7.4.4 ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [PATCH sugar] Only show DOCUMENTS folder when it is not $HOME
'xdg-user-dir DOCUMENTS' will return $HOME when DOCUMENTS does not exist, only display the DOCUMENTS folder when the actual folder exists Signed-off-by: Simon Schampijer --- src/jarabe/journal/volumestoolbar.py |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py index 84d9e31..1cc764f 100644 --- a/src/jarabe/journal/volumestoolbar.py +++ b/src/jarabe/journal/volumestoolbar.py @@ -67,8 +67,9 @@ def _get_documents_path(): try: pipe = subprocess.Popen(['xdg-user-dir', 'DOCUMENTS'], stdout=subprocess.PIPE) -documents_path = pipe.communicate()[0].strip() -if os.path.exists(documents_path): +documents_path = os.path.normpath(pipe.communicate()[0].strip()) +if os.path.exists(documents_path) and \ +os.environ.get('HOME') != documents_path: return documents_path except OSError, exception: if exception.errno != errno.ENOENT: -- 1.7.4.4 ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [PATCH sugar] Only show DOCUMENTS folder when it is not $HOME
Shouldn't we be comparing normalized versions of paths in case symbolic links are present, or there are extra "." or "/" characters present? I'm not sure if the string comparison proposed is guaranteed to work in all cases. On Fri, Sep 2, 2011 at 11:02 AM, Simon Schampijer wrote: > 'xdg-user-dir DOCUMENTS' will return $HOME when DOCUMENTS > does not exist, only display the DOCUMENTS folder > when the actual folder exists > > Signed-off-by: Simon Schampijer > --- > src/jarabe/journal/volumestoolbar.py |3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > > diff --git a/src/jarabe/journal/volumestoolbar.py > b/src/jarabe/journal/volumestoolbar.py > index 84d9e31..3aa37da 100644 > --- a/src/jarabe/journal/volumestoolbar.py > +++ b/src/jarabe/journal/volumestoolbar.py > @@ -68,7 +68,8 @@ def _get_documents_path(): > pipe = subprocess.Popen(['xdg-user-dir', 'DOCUMENTS'], > stdout=subprocess.PIPE) > documents_path = pipe.communicate()[0].strip() > -if os.path.exists(documents_path): > +if os.path.exists(documents_path) and \ > +os.environ.get('HOME') + '/' != documents_path: > return documents_path > except OSError, exception: > if exception.errno != errno.ENOENT: > -- > 1.7.4.4 > > ___ > Sugar-devel mailing list > Sugar-devel@lists.sugarlabs.org > http://lists.sugarlabs.org/listinfo/sugar-devel > ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [PATCH sugar] Only show DOCUMENTS folder when it is not $HOME
Tested-by: Gonzalo Odiard Acked-by: Gonzalo Odiard ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [PATCH sugar] Only show DOCUMENTS folder when it is not $HOME
On 09/06/2011 08:10 PM, Gonzalo Odiard wrote: Tested-by: Gonzalo Odiard Acked-by: Gonzalo Odiard Thanks Gonzalo for testing and the review, pushed as: http://git.sugarlabs.org/sugar/mainline/commit/e4f7d81e73fe445f4d4d7b1b168855835fcc09ea Sidenote: The guideline says that only a maintainer can acknowledge a patch. For a review it is 'Reviewed-by'. Regards, Simon ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel