Back to the main page.

Bug 3071 - ft_version leaves excessive tmp files

Status CLOSED FIXED
Reported 2016-02-17 02:10:00 +0100
Modified 2019-08-10 12:41:49 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P5 minor
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Roeland Hancock - 2016-02-17 02:10:24 +0100

When Fieldtrip is obtained via git, calls to ft_version (in version e744a4b245f397215b0c16c990a84efe826258b3) create temp files that are not reliably cleaned up on all systems. In my case, repeated indirect (e.g. through ft_selectdata) calls to ft_version create a crippling number of files in /tmp.


Robert Oostenveld - 2016-02-17 09:23:03 +0100

I would not expect ft_version to write anything to disk. Could you be more specific?


Roeland Hancock - 2016-02-17 17:33:45 +0100

On line 79, ft_version calls tempname, which creates a temporary file. An alternative approach to getting the commit number would be something like [status, output]=system('git log --pretty=format:"%H" -1'); which simply returns the commit number in output, without the need for parsing temporary files. Lines 78-101: elseif isgit tmpfile = tempname; olddir = pwd(); cd(ftpath); [status, output] = system(sprintf('git show > %s', tmpfile)); cd(olddir); if status > 0 % FIXME the command line tools will probably not be available on windows error('you seem to have an GIT development copy of FieldTrip, yet ''git show'' does not work as expected'); end fp = fopen(tmpfile); if fp>0 line = fgetl(fp); % the first line contains the commit number fclose(fp); rev = regexp(line, ' ', 'split'); rev = rev{2}; % this is a string like 4d3c309129f12146885120c2853a11362e048ea7 ftver = rev; else ftver = 'unknown'; end


Robert Oostenveld - 2016-02-17 17:57:33 +0100

(In reply to Roeland Hancock from comment #2) Ah I see. Silly that the temp file does not get removed afterwards. Your proposal is indeed much better. I tried it with https://github.com/robertoostenveld/fieldtrip/commit/c3789e60800d5999625aefc46adb1cb177191df2 which is basically elseif isgit % use git system call to determine latest revision olddir = pwd(); cd(ftpath); [status, output] = system('git log -1 --pretty=format:"%H"'); cd(olddir); if status > 0 % FIXME the command line tools will probably not be available on windows error('you seem to have an GIT development copy of FieldTrip, yet ''git'' does not work as expected'); else ftver = output; end Hwoever, from the command line git log -1 --pretty=format:"%H and also git log -1 work fine, but from within MATLAB both system calls cause MATLAB to hang. Does it work for you?


Robert Oostenveld - 2016-02-17 17:57:50 +0100

note to self, see https://github.com/robertoostenveld/fieldtrip/commits/bug3071-ft_version


Roeland Hancock - 2016-02-17 18:05:21 +0100

(In reply to Robert Oostenveld from comment #3) Ah, that does hang in Matlab. But [status,output]=system('git --no-pager log -1 --pretty=format:"%H"'); seems to work.


Robert Oostenveld - 2017-08-16 16:48:51 +0200

hmm, this has actually been fixed already quite some time ago. Time to close this bug.


Robert Oostenveld - 2019-08-10 12:35:36 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue on https://github.com/fieldtrip/fieldtrip/issues.


Robert Oostenveld - 2019-08-10 12:41:49 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue on https://github.com/fieldtrip/fieldtrip/issues.