Fix misleading 'file-has-changed' message in spyder on CIFS.

The issue has been reported to upstream in spyder-ide/21877.
The patch implements a more tolerant file modification detection
and only reports differences greater than 1000 ms.
This commit is contained in:
Andreas B. Mundt 2024-06-21 08:25:28 +02:00
parent 040b017b40
commit 55b89ac912
2 changed files with 28 additions and 0 deletions

View file

@ -373,6 +373,11 @@
chdir: /tmp/ chdir: /tmp/
when: new_kio.changed | default(false) when: new_kio.changed | default(false)
- name: Patch spyder to fix 'file-has-changed' issues on CIFS
ansible.posix.patch:
src: spyder.patch
dest: /usr/lib/python3/dist-packages/spyder/plugins/editor/widgets/editor.py
################# #################
- name: Timestamp successfull run and send up-to-date report - name: Timestamp successfull run and send up-to-date report

23
spyder.patch Normal file
View file

@ -0,0 +1,23 @@
--- /usr/lib/python3/dist-packages/spyder/plugins/editor/widgets/editor.py 2024-06-20 07:16:54.096395325 +0200
+++ /usr/lib/python3/dist-packages/spyder/plugins/editor/widgets/editor.py 2024-06-20 14:39:07.693577124 +0200
@@ -2370,15 +2370,16 @@
else:
# Else, testing if it has been modified elsewhere:
lastm = QFileInfo(finfo.filename).lastModified()
- if to_text_string(lastm.toString()) \
- != to_text_string(finfo.lastmodified.toString()):
+ dt = finfo.lastmodified.msecsTo(lastm)
+ if dt > 1000:
if finfo.editor.document().isModified():
self.msgbox = QMessageBox(
QMessageBox.Question,
self.title,
- _("<b>%s</b> has been modified outside Spyder."
+ _("It looks like <b>%s</b> has been modified "
+ "outside Spyder. The working copy is from %i milliseconds ago."
"<br>Do you want to reload it and lose all "
- "your changes?") % name,
+ "your changes?") % (name, dt),
QMessageBox.Yes | QMessageBox.No,
self)
answer = self.msgbox.exec_()