On Sunday, November 18, 2018 at 7:22:20 PM UTC+1, Rob wrote:
>
> Thanks for the suggested workaround. However, I don't want to bypass the 
> warning, I need to explore why the warning is happening at all (it 
> shouldn't). In order to do that, I need to simply get the file times (new 
> and old) and the checksums (new and old) and write them to the log pane.
>
> So, as an example, looking in the leoExternalFiles.py file, I find this 
> node: `class ExternalFilesController>efc.utilities>efc.get_mtime`:
>
> def get_mtime(self, path):
>     '''Return the modification time for the path.'''
>     return g.os_path_getmtime(path)
>
>
> Then later in the same path: `efc.has_changed'
>
> def has_changed(self, c, path):
>     '''Return True if p's external file has changed outside of Leo.'''
>     if not g.os_path_exists(path):
>         return False
>     if g.os_path_isdir(path):
>         return False
>     #
>     # First, check the modification times.
>     old_time = self.get_time(path)
>     new_time = self.get_mtime(path)
>     if not old_time:
>         # Initialize.
>         self.set_time(path, new_time)
>         self.checksum_d[path] = self.checksum(path)
>         return False
>     if old_time == new_time:
>         # print('%s:times match %s %s' % (tag,c.shortFileName(),path))
>         return False
> #...(code continues)...
>
>
> Here, it appears to call the function (method?) defined earlier to get the 
> file times using `self` and `path`, but I don't see anywhere in the file 
> how to define what `self` and `path` are. I'm sure this is probably pretty 
> basic Python stuff, but it's not obvious to me:-(
>

Well, self in this code is g.app.externalFilesController and the path is 
the full filename of the file being checked. 

Now, I think that the problem is in checking for equality of two float 
numbers, which can cause whole bunch of surprising effects. Try to replace 
the line:
    if old_time == new_time:
# with something like
    if abs(old_time - new_time) < 0.0001:

and see if it solves your problem. 

I guess your files in the cloud have different time granularity than 
ordinary files on your hard disc. That can cause the modification time to 
be slightly different than the value returned by your system. 

That could explain why the old_time and new_time have different values, but 
not why checksum values are different. 

The checksum values can differ if there is a difference in line endings in 
cloud and your operating system. Leo would treat both files as the same 
comparing their text content, but still they would have different checksum 
values.

While playing with the script I posted earlier, I have noticed that saving 
Leo document, do not change immediately checksum values in efc. They get 
re-calculated the next time idle processing come to visit particular 
commander. So, it is possible that efc contains stale checksum values.

Vitalije

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to