Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pyfs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pyfs
Commits
d72f76c6
Commit
d72f76c6
authored
Apr 23, 2012
by
btimby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed problem with Chrome using file as a directory
parent
3a283254
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletions
+14
-1
fs/expose/ftp.py
+14
-1
No files found.
fs/expose/ftp.py
View file @
d72f76c6
...
...
@@ -18,6 +18,7 @@ loopback address.
import
os
import
stat
import
time
import
errno
from
functools
import
wraps
from
pyftpdlib
import
ftpserver
...
...
@@ -90,6 +91,16 @@ class FTPFS(ftpserver.AbstractedFS):
return
self
.
fs
.
open
(
path
,
mode
)
def
chdir
(
self
,
path
):
# TODO: can the following conditional checks be farmed out to the fs?
# If we don't raise an error here for files, then the FTP server will
# happily allow the client to CWD into a file. We really only want to
# allow that for directories.
if
self
.
fs
.
isfile
(
path
):
raise
OSError
(
errno
.
ENOTDIR
,
'Not a directory'
)
# similarly, if we don't check for existence, the FTP server will allow
# the client to CWD into a non-existent directory.
if
not
self
.
fs
.
exists
(
path
):
raise
OSError
(
errno
.
ENOENT
,
'Does not exist'
)
self
.
_cwd
=
self
.
ftp2fs
(
path
)
@convert_fs_errors
...
...
@@ -147,7 +158,8 @@ class FTPFS(ftpserver.AbstractedFS):
elif
'st_mtime'
in
kwargs
:
# As a last resort, just copy the modified time.
kwargs
[
'st_ctime'
]
=
kwargs
[
'st_mtime'
]
mode
=
0777
# Not executable by default, Chrome uses the exec flag to denote directories.
mode
=
0660
# Merge in the type (dir or file). File is tested first, some file systems
# such as ArchiveMountFS treat archive files as directories too. By checking
# file first, any such files will be only files (not directories).
...
...
@@ -155,6 +167,7 @@ class FTPFS(ftpserver.AbstractedFS):
mode
|=
stat
.
S_IFREG
elif
self
.
fs
.
isdir
(
path
):
mode
|=
stat
.
S_IFDIR
mode
|=
0110
# Merge in exec bit
kwargs
[
'st_mode'
]
=
mode
return
FakeStat
(
**
kwargs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment