[Django] #27644: FileSystemStorage --- get_created_time method does not work on Unix

9 views
Skip to first unread message

Django

unread,
Dec 26, 2016, 2:57:17 PM12/26/16
to django-...@googlegroups.com
#27644: FileSystemStorage --- get_created_time method does not work on Unix
------------------------------------------------+------------------------
Reporter: Jonathan Verner | Owner: nobody
Type: Bug | Status: new
Component: File uploads/storage | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
The method {{{get_created_time}}} uses {{{os.path.getctime}}} which only
returns the creation time on Windows. On Unix it returns the **change
time** , i.e. the last time the inode attributes were modified (see
[http://stackoverflow.com/questions/237079/how-to-get-file-creation-
modification-date-times-in-python]). The documentation says that
For storage systems unable to return the creation time this will raise
NotImplementedError
so the correct behaviour would be, IHMO, to raise a
{{{NotImplementedError}}} on Unix platforms. I am not sure whether the
method is used anywhere---searching on github only came up with uses in
tests, docs and the place where it is defined. Also, as noted by a
commenter on the above stackoverflow question, it doesn't seem to be a
useful value anyway:

Frankly, file creation time is usually fairly useless. When you open
an existing file for write with mode "w", it's not replacing it, it just
opens the existing file and truncates it. Even though the file contents
are completely unrelated to whatever it had on creation, you'd still be
told the file was "created" well before the current version. Conversely,
editors that use atomic replace on save (original file is replaced by new
work-in-progress temp file) would show a more recent creation date, even
if you just deleted one character. Use the modification time, don't grub
for creation time.

So it might make sense to remove the method altogether.

--
Ticket URL: <https://code.djangoproject.com/ticket/27644>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 26, 2016, 3:06:19 PM12/26/16
to django-...@googlegroups.com
#27644: FileSystemStorage --- get_created_time method does not work on Unix
-------------------------------------+-------------------------------------

Reporter: Jonathan Verner | Owner: nobody
Type: Bug | Status: new
Component: File | Version: 1.10
uploads/storage |
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Adam Chainz):

Perhaps `ctime` is good enough though, making the presumption that the
inode attributes only change at creation time?

--
Ticket URL: <https://code.djangoproject.com/ticket/27644#comment:1>

Django

unread,
Dec 27, 2016, 5:35:08 AM12/27/16
to django-...@googlegroups.com
#27644: FileSystemStorage --- get_created_time method does not work on Unix
-------------------------------------+-------------------------------------

Reporter: Jonathan Verner | Owner: nobody
Type: Bug | Status: new
Component: File | Version: 1.10
uploads/storage |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Jonathan Verner):

Replying to [comment:1 Adam Chainz]:


> Perhaps `ctime` is good enough though, making the presumption that the
inode attributes only change at creation time?

Unfortunately, that is not the case: `ctime` changes at least as often as
`mtime` does---updating the `mtime` changes inode attributes.

--
Ticket URL: <https://code.djangoproject.com/ticket/27644#comment:2>

Django

unread,
Dec 27, 2016, 8:49:41 AM12/27/16
to django-...@googlegroups.com
#27644: Document FileSystemStorage.get_created_time() limitation on Unix
--------------------------------------+------------------------------------

Reporter: Jonathan Verner | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham):

* component: File uploads/storage => Documentation
* stage: Unreviewed => Accepted
* type: Bug => Cleanup/optimization


Comment:

Accepting as a documentation clarification for now. I'm not sure if
changing the method's implementation is worth it, but I think it would
require a deprecation path. If you want to pursue that, please raise the
idea on the DevelopersMailingList to get a consensus.

--
Ticket URL: <https://code.djangoproject.com/ticket/27644#comment:3>

Django

unread,
Apr 6, 2017, 12:06:51 PM4/6/17
to django-...@googlegroups.com
#27644: Document FileSystemStorage.get_created_time() limitation on Unix
-------------------------------------+-------------------------------------
Reporter: Jonathan Verner | Owner: Ingo
Type: | Klöcker
Cleanup/optimization | Status: assigned

Component: Documentation | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ingo Klöcker):

* status: new => assigned
* owner: nobody => Ingo Klöcker


Comment:

I'll look into this.

--
Ticket URL: <https://code.djangoproject.com/ticket/27644#comment:4>

Django

unread,
Apr 7, 2017, 3:47:35 AM4/7/17
to django-...@googlegroups.com
#27644: Document FileSystemStorage.get_created_time() limitation on Unix
-------------------------------------+-------------------------------------
Reporter: Jonathan Verner | Owner: Ingo
Type: | Klöcker
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ingo Klöcker):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/8319 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27644#comment:5>

Django

unread,
Apr 8, 2017, 7:44:02 AM4/8/17
to django-...@googlegroups.com
#27644: Document FileSystemStorage.get_created_time() limitation on Unix
-------------------------------------+-------------------------------------
Reporter: Jonathan Verner | Owner: Ingo
Type: | Klöcker
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/27644#comment:6>

Django

unread,
Apr 15, 2017, 7:35:23 AM4/15/17
to django-...@googlegroups.com
#27644: Document FileSystemStorage.get_created_time() limitation on Unix
-------------------------------------+-------------------------------------
Reporter: Jonathan Verner | Owner: Ingo
Type: | Klöcker
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ingo Klöcker):

* needs_better_patch: 1 => 0


Comment:

I've improved the patch.

--
Ticket URL: <https://code.djangoproject.com/ticket/27644#comment:7>

Django

unread,
Apr 26, 2017, 1:55:46 PM4/26/17
to django-...@googlegroups.com
#27644: Document FileSystemStorage.get_created_time() limitation on Unix
-------------------------------------+-------------------------------------
Reporter: Jonathan Verner | Owner: Ingo
Type: | Klöcker
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.10
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"f3ac398dd595c43f551502c742b0b3cbe8440e50" f3ac398d]:
{{{
#!CommitTicketReference repository=""
revision="f3ac398dd595c43f551502c742b0b3cbe8440e50"
Fixed #27644 -- Doc'd FileSystemStorage.get_created_time().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27644#comment:8>

Django

unread,
Apr 26, 2017, 1:56:00 PM4/26/17
to django-...@googlegroups.com
#27644: Document FileSystemStorage.get_created_time() limitation on Unix
-------------------------------------+-------------------------------------
Reporter: Jonathan Verner | Owner: Ingo
Type: | Klöcker
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.10
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"4678957b4efae23204d954ac912c77d7cf122f26" 4678957b]:
{{{
#!CommitTicketReference repository=""
revision="4678957b4efae23204d954ac912c77d7cf122f26"
[1.11.x] Fixed #27644 -- Doc'd FileSystemStorage.get_created_time().

Backport of f3ac398dd595c43f551502c742b0b3cbe8440e50 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27644#comment:9>

Reply all
Reply to author
Forward
0 new messages