Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve timestamp of modified file #4

Open
nepto opened this issue Apr 28, 2012 · 1 comment
Open

Preserve timestamp of modified file #4

nepto opened this issue Apr 28, 2012 · 1 comment
Labels

Comments

@nepto
Copy link

nepto commented Apr 28, 2012

I have a patch for preserving timestamp of modified file.
You can include it into next version.

--- qtfaststart.ori 2012-02-22 03:45:51.290130562 +0100
+++ qtfaststart 2012-02-22 03:36:45.574130608 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python

 """
     Command line script for convenience. If this is in your path, you should
@@ -12,6 +12,7 @@
 import shutil
 import sys
 import tempfile
+from stat import *

 # Add parent directory to sys.path so that running from dev environment works
 sys.path.append(os.path.dirname(os.path.dirname((os.path.abspath(__file__)))))
@@ -72,7 +73,9 @@
     if options.sample:
         # Create a small sample (4 MiB)
         limit = 4 * (1024 ** 2)
-    
+
+    stats = os.stat(args[0])
+    mtime, atime = (stats[ST_MTIME], stats[ST_ATIME])
     try:
         processor.process(args[0], outfile, limit = limit)
     except FastStartException:
@@ -82,4 +85,7 @@
     if len(args) == 1:
         # Move temp file to replace original
         shutil.move(outfile, args[0])
+        os.utime(args[0], (atime, mtime))
+    else:
+        os.utime(outfile, (atime, mtime))
@nepto
Copy link
Author

nepto commented Jan 28, 2014

Here is a patch for the current version:

--- /usr/local/lib/python2.6/dist-packages/qtfaststart/command.py   2014-01-28 21:47:31.000000000 +0100
+++ /root/command.py    2014-01-28 22:12:28.000000000 +0100
@@ -6,6 +6,7 @@
 import shutil
 import sys
 import tempfile
+from stat import *

 from optparse import OptionParser
 from qtfaststart import VERSION
@@ -71,6 +72,9 @@
     if options.sample:
         # Create a small sample (4 MiB)
         limit = 4 * (1024 ** 2)
+        
+    stats = os.stat(args[0])
+    mtime, atime = (stats[ST_MTIME], stats[ST_ATIME])

     try:
         processor.process(args[0], outfile, limit = limit, to_end = options.to_end)
@@ -81,3 +85,6 @@
     if len(args) == 1:
         # Move temp file to replace original
         shutil.move(outfile, args[0])
+        os.utime(args[0], (atime, mtime))
+    else:
+        os.utime(outfile, (atime, mtime))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant