equal
deleted
inserted
replaced
43 import hashlib |
43 import hashlib |
44 import inspect |
44 import inspect |
45 import os |
45 import os |
46 import re |
46 import re |
47 import socket |
47 import socket |
|
48 import stat |
48 import struct |
49 import struct |
49 import time |
50 import time |
50 |
51 |
51 from .i18n import _ |
52 from .i18n import _ |
52 |
53 |
159 race conditions). We need to calculate confighash without importing. |
160 race conditions). We need to calculate confighash without importing. |
160 """ |
161 """ |
161 def trystat(path): |
162 def trystat(path): |
162 try: |
163 try: |
163 st = os.stat(path) |
164 st = os.stat(path) |
164 return (st.st_mtime, st.st_size) |
165 return (st[stat.ST_MTIME], st.st_size) |
165 except OSError: |
166 except OSError: |
166 # could be ENOENT, EPERM etc. not fatal in any case |
167 # could be ENOENT, EPERM etc. not fatal in any case |
167 pass |
168 pass |
168 return _hashlist(map(trystat, paths))[:12] |
169 return _hashlist(map(trystat, paths))[:12] |
169 |
170 |
544 os.symlink(os.path.basename(self._realaddress), tempaddress) |
545 os.symlink(os.path.basename(self._realaddress), tempaddress) |
545 util.rename(tempaddress, self._baseaddress) |
546 util.rename(tempaddress, self._baseaddress) |
546 |
547 |
547 def _issocketowner(self): |
548 def _issocketowner(self): |
548 try: |
549 try: |
549 stat = os.stat(self._realaddress) |
550 st = os.stat(self._realaddress) |
550 return (stat.st_ino == self._socketstat.st_ino and |
551 return (st.st_ino == self._socketstat.st_ino and |
551 stat.st_mtime == self._socketstat.st_mtime) |
552 st[stat.ST_MTIME] == self._socketstat[stat.ST_MTIME]) |
552 except OSError: |
553 except OSError: |
553 return False |
554 return False |
554 |
555 |
555 def unlinksocket(self, address): |
556 def unlinksocket(self, address): |
556 if not self._issocketowner(): |
557 if not self._issocketowner(): |