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
839a1f68
Commit
839a1f68
authored
Jun 16, 2009
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a locking bug in MountFS.getsize
parent
654209fd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
76 deletions
+16
-76
fs/mountfs.py
+16
-76
No files found.
fs/mountfs.py
View file @
839a1f68
#!/usr/bin/env python
from
base
import
*
from
objecttree
import
ObjectTree
from
memoryfs
import
MemoryFS
from
fs.base
import
*
from
fs.objecttree
import
ObjectTree
class
DirMount
(
object
):
...
...
@@ -53,9 +52,8 @@ class MountFS(FS):
return
self
,
head_path
,
tail_path
@synchronize
def
desc
(
self
,
path
):
self
.
_lock
.
acquire
()
try
:
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
self
:
if
fs
.
isdir
(
path
):
...
...
@@ -63,12 +61,9 @@ class MountFS(FS):
else
:
return
"Mounted file"
return
"Mounted dir, maps to path
%
s on
%
s"
%
(
delegate_path
,
str
(
fs
))
finally
:
self
.
_lock
.
release
()
@synchronize
def
isdir
(
self
,
path
):
self
.
_lock
.
acquire
()
try
:
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
raise
ResourceNotFoundError
(
path
)
...
...
@@ -78,13 +73,9 @@ class MountFS(FS):
return
isinstance
(
object
,
dict
)
else
:
return
fs
.
isdir
(
delegate_path
)
finally
:
self
.
_lock
.
release
()
@synchronize
def
isfile
(
self
,
path
):
self
.
_lock
.
acquire
()
try
:
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
return
ResourceNotFoundError
(
path
)
...
...
@@ -94,13 +85,9 @@ class MountFS(FS):
return
type
(
object
)
is
MountFS
.
FileMount
else
:
return
fs
.
isfile
(
delegate_path
)
finally
:
self
.
_lock
.
release
()
@synchronize
def
listdir
(
self
,
path
=
"/"
,
wildcard
=
None
,
full
=
False
,
absolute
=
False
,
dirs_only
=
False
,
files_only
=
False
):
self
.
_lock
.
acquire
()
try
:
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
...
...
@@ -134,24 +121,17 @@ class MountFS(FS):
paths
=
[
pathjoin
(
path
,
p
)
for
p
in
paths
]
return
paths
finally
:
self
.
_lock
.
release
()
@synchronize
def
makedir
(
self
,
path
,
recursive
=
False
,
allow_recreate
=
False
):
path
=
normpath
(
path
)
self
.
_lock
.
acquire
()
try
:
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
self
:
raise
UnsupportedError
(
"make directory"
,
msg
=
"Can only makedir for mounted paths"
)
return
fs
.
makedir
(
delegate_path
,
recursive
=
recursive
,
allow_recreate
=
allow_recreate
)
finally
:
self
.
_lock
.
release
()
@synchronize
def
open
(
self
,
path
,
mode
=
"r"
,
**
kwargs
):
self
.
_lock
.
acquire
()
try
:
path
=
normpath
(
path
)
object
=
self
.
mount_tree
.
get
(
path
,
None
)
if
type
(
object
)
is
MountFS
.
FileMount
:
...
...
@@ -165,31 +145,19 @@ class MountFS(FS):
return
fs
.
open
(
delegate_path
,
mode
,
**
kwargs
)
finally
:
self
.
_lock
.
release
()
@synchronize
def
exists
(
self
,
path
):
self
.
_lock
.
acquire
()
try
:
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
return
False
if
fs
is
self
:
return
path
in
self
.
mount_tree
return
fs
.
exists
(
delegate_path
)
finally
:
self
.
_lock
.
release
()
@synchronize
def
remove
(
self
,
path
):
self
.
_lock
.
acquire
()
try
:
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
...
...
@@ -198,14 +166,8 @@ class MountFS(FS):
raise
UnsupportedError
(
"remove file"
,
msg
=
"Can only remove paths within a mounted dir"
)
return
fs
.
remove
(
delegate_path
)
finally
:
self
.
_lock
.
release
()
@synchronize
def
removedir
(
self
,
path
,
recursive
=
False
,
force
=
False
):
self
.
_lock
.
acquire
()
try
:
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
...
...
@@ -217,16 +179,10 @@ class MountFS(FS):
return
fs
.
removedir
(
delegate_path
,
recursive
,
force
)
finally
:
self
.
_lock
.
release
()
@synchronize
def
rename
(
self
,
src
,
dst
):
if
not
issamedir
(
src
,
dst
):
raise
ValueError
(
"Destination path must the same directory (use the move method for moving to a different directory)"
)
self
.
_lock
.
acquire
()
try
:
fs1
,
mount_path1
,
delegate_path1
=
self
.
_delegate
(
src
)
fs2
,
mount_path2
,
delegate_path2
=
self
.
_delegate
(
dst
)
...
...
@@ -246,11 +202,9 @@ class MountFS(FS):
raise
ResourceNotFoundError
(
src
)
# TODO!
raise
UnsupportedError
(
"rename resource"
,
path
=
src
)
finally
:
self
.
_lock
.
release
()
@synchronize
def
mountdir
(
self
,
path
,
fs
):
"""Mounts a directory on a given path.
...
...
@@ -258,26 +212,17 @@ class MountFS(FS):
fs -- A filesystem object to mount
"""
self
.
_lock
.
acquire
()
try
:
path
=
normpath
(
path
)
self
.
mount_tree
[
path
]
=
MountFS
.
DirMount
(
path
,
fs
)
finally
:
self
.
_lock
.
release
()
mount
=
mountdir
@synchronize
def
mountfile
(
self
,
path
,
open_callable
=
None
,
info_callable
=
None
):
self
.
_lock
.
acquire
()
try
:
path
=
normpath
(
path
)
self
.
mount_tree
[
path
]
=
MountFS
.
FileMount
(
path
,
callable
,
info_callable
)
finally
:
self
.
_lock
.
release
()
@synchronize
def
getinfo
(
self
,
path
):
self
.
_lock
.
acquire
()
try
:
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
...
...
@@ -290,12 +235,9 @@ class MountFS(FS):
return
self
.
mount_tree
[
path
]
.
info_callable
(
path
)
return
{}
return
fs
.
getinfo
(
delegate_path
)
finally
:
self
.
_lock
.
release
()
@synchronize
def
getsize
(
self
,
path
):
self
.
_lock
.
acquire
()
try
:
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
...
...
@@ -312,6 +254,4 @@ class MountFS(FS):
return
size
return
fs
.
getinfo
(
delegate_path
)
.
get
(
"size"
,
None
)
except
:
self
.
_lock
.
release
()
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