summaryrefslogtreecommitdiff
path: root/httpfs
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2016-02-14 16:06:12 +0100
committerYves Fischer <yvesf-git@xapek.org>2016-02-14 16:52:00 +0100
commit4875d6229f6d782e0767fa63811f8274cb292199 (patch)
tree739909dd382a70b506e0223061214d0af36f2fba /httpfs
parent058a9212ccf2c461cc25cfc529ed3085e3c4320a (diff)
downloadfuse-httpfs-4875d6229f6d782e0767fa63811f8274cb292199.tar.gz
fuse-httpfs-4875d6229f6d782e0767fa63811f8274cb292199.zip
Do not create directory link to root directory
Diffstat (limited to 'httpfs')
-rw-r--r--httpfs/__init__.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/httpfs/__init__.py b/httpfs/__init__.py
index 1d04bd8..9a2d2c9 100644
--- a/httpfs/__init__.py
+++ b/httpfs/__init__.py
@@ -3,7 +3,6 @@ import sys
import time
import netrc
import logging
-import logging.config
from urllib.parse import quote, unquote
from email.utils import parsedate
from html.parser import HTMLParser
@@ -207,10 +206,11 @@ class RelativeLinkCollector(HTMLParser):
attrs = dict(attrs)
if "href" in attrs:
href = attrs["href"]
- if "/" in href[:-1] or href[0] == ".":
+ if "/" in href[:-1] or href[0] == "." or href == "/":
return
if href[-1:] == "/":
+ # ends with / => directory
d = Directory.fromPath(self.parent, href[:-1])
self.entries[unquote(href[:-1])] = d
else:
@@ -293,7 +293,7 @@ class Httpfs(fuse.LoggingMixIn, fuse.Operations):
r = d.getSession().head(url, timeout=Config.timeout,
allow_redirects=True)
if r.status_code == 200:
- logging.info("Create directory for path: {} " +
+ logging.info("Create directory for path: {} "
"at: {}".format(path, url))
prevEntry.entries[lastElement] = d
else:
@@ -310,9 +310,12 @@ class Httpfs(fuse.LoggingMixIn, fuse.Operations):
raise fuse.FuseOSError(EBADF)
if not entry.initialized:
entry.init()
- return [(".", entry.getAttr(), 0),
- ("..", (entry.parent and entry.parent.getAttr() or None), 0)] \
- + [(it.name, it.getAttr(), 0) for it in entry.entries.values()]
+ return [
+ (".", entry.getAttr(), 0),
+ ("..", (entry.parent and entry.parent.getAttr() or None), 0)
+ ] + [
+ (it.name, it.getAttr(), 0) for it in entry.entries.values()
+ ]
except Exception as e:
logging.exception("Error in readdir(%s)", path)
raise fuse.FuseOSError(EIO)