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
7d801b21
Commit
7d801b21
authored
Feb 05, 2011
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CacheFSMixin: clear cache when an open file is modified
parent
eb761f06
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletions
+23
-1
fs/remote.py
+23
-1
No files found.
fs/remote.py
View file @
7d801b21
...
...
@@ -550,7 +550,29 @@ class CacheFSMixin(WrapFS):
else
:
if
not
fs
.
utils
.
isfile
(
super
(
CacheFSMixin
,
self
),
path
,
ci
.
info
):
raise
ResourceInvalidError
(
path
)
return
super
(
CacheFSMixin
,
self
)
.
open
(
path
,
mode
,
**
kwds
)
f
=
super
(
CacheFSMixin
,
self
)
.
open
(
path
,
mode
,
**
kwds
)
if
"w"
in
mode
or
"a"
in
mode
or
"+"
in
mode
:
with
self
.
__cache_lock
:
self
.
__cache
.
clear
(
path
)
f
=
self
.
_CacheInvalidatingFile
(
self
,
path
,
f
,
mode
)
return
f
class
_CacheInvalidatingFile
(
FileWrapper
):
def
__init__
(
self
,
owner
,
path
,
wrapped_file
,
mode
=
None
):
self
.
path
=
path
sup
=
super
(
CacheFSMixin
.
_CacheInvalidatingFile
,
self
)
sup
.
__init__
(
wrapped_file
,
mode
)
self
.
owner
=
owner
def
_write
(
self
,
string
,
flushing
=
False
):
with
self
.
owner
.
_CacheFSMixin__cache_lock
:
self
.
owner
.
_CacheFSMixin__cache
.
clear
(
self
.
path
)
sup
=
super
(
CacheFSMixin
.
_CacheInvalidatingFile
,
self
)
return
sup
.
_write
(
string
,
flushing
=
flushing
)
def
_truncate
(
self
,
size
):
with
self
.
owner
.
_CacheFSMixin__cache_lock
:
self
.
owner
.
_CacheFSMixin__cache
.
clear
(
self
.
path
)
sup
=
super
(
CacheFSMixin
.
_CacheInvalidatingFile
,
self
)
return
sup
.
_truncate
(
size
)
def
exists
(
self
,
path
):
try
:
...
...
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