Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
211af7df
Commit
211af7df
authored
Sep 18, 2013
by
R David Murray
Browse files
Options
Browse Files
Download
Plain Diff
Merge #19037: adjust file times *before* moving maildir files into place.
parents
62e02b39
34658cdf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
Lib/mailbox.py
Lib/mailbox.py
+13
-5
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/mailbox.py
View file @
211af7df
...
...
@@ -308,6 +308,12 @@ class Maildir(Mailbox):
suffix
=
''
uniq
=
os
.
path
.
basename
(
tmp_file
.
name
).
split
(
self
.
colon
)[
0
]
dest
=
os
.
path
.
join
(
self
.
_path
,
subdir
,
uniq
+
suffix
)
if
isinstance
(
message
,
MaildirMessage
):
os
.
utime
(
tmp_file
.
name
,
(
os
.
path
.
getatime
(
tmp_file
.
name
),
message
.
get_date
()))
# No file modification should be done after the file is moved to its
# final position in order to prevent race conditions with changes
# from other programs
try
:
if
hasattr
(
os
,
'link'
):
os
.
link
(
tmp_file
.
name
,
dest
)
...
...
@@ -321,8 +327,6 @@ class Maildir(Mailbox):
%
dest
)
else
:
raise
if
isinstance
(
message
,
MaildirMessage
):
os
.
utime
(
dest
,
(
os
.
path
.
getatime
(
dest
),
message
.
get_date
()))
return
uniq
def
remove
(
self
,
key
):
...
...
@@ -354,11 +358,15 @@ class Maildir(Mailbox):
else
:
suffix
=
''
self
.
discard
(
key
)
tmp_path
=
os
.
path
.
join
(
self
.
_path
,
temp_subpath
)
new_path
=
os
.
path
.
join
(
self
.
_path
,
subdir
,
key
+
suffix
)
os
.
rename
(
os
.
path
.
join
(
self
.
_path
,
temp_subpath
),
new_path
)
if
isinstance
(
message
,
MaildirMessage
):
os
.
utime
(
new_path
,
(
os
.
path
.
getatime
(
new_path
),
message
.
get_date
()))
os
.
utime
(
tmp_path
,
(
os
.
path
.
getatime
(
tmp_path
),
message
.
get_date
()))
# No file modification should be done after the file is moved to its
# final position in order to prevent race conditions with changes
# from other programs
os
.
rename
(
tmp_path
,
new_path
)
def
get_message
(
self
,
key
):
"""Return a Message representation or raise a KeyError."""
...
...
Misc/NEWS
View file @
211af7df
...
...
@@ -12,6 +12,10 @@ Core and Builtins
Library
-------
-
Issue
#
19037
:
The
mailbox
module
now
makes
all
changes
to
maildir
files
before
moving
them
into
place
,
to
avoid
race
conditions
with
other
programs
that
may
be
accessing
the
maildir
directory
.
-
Issue
#
14984
:
On
POSIX
systems
,
when
netrc
is
called
without
a
filename
argument
(
and
therefore
is
reading
the
user
's $HOME/.netrc file), it now
enforces the same security rules as typical ftp clients: the .netrc file must
...
...
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