Dave Perrett

Filesystem Path Is Neither a File Nor a Directory 160013 - SVN / Trac Error

linux, programming, python, version control, web

Recently I had an SVN repository with a couple of corrupt revisions that I couldn’t figure out how to fix, which caused Trac to stop displaying revisions after the corruption.

Trying trac-admin resync was no help, throwing this exception :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ sudo trac-admin /path/to/your/repository/ resync
Resyncing repository history...
Traceback (most recent call last):
  File "/usr/bin/trac-admin", line 7, in ?
    sys.exit(
  File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/admin/console.py", line 1249, in run
    return admin.onecmd(command)
  File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/admin/console.py", line 104, in onecmd
    rv = cmd.Cmd.onecmd(self, line) or 0
  File "/usr/lib64/python2.4/cmd.py", line 219, in onecmd
    return func(arg)
  File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/admin/console.py", line 632, in do_resync
    repos = env.get_repository().sync(self._resync_feedback)
  File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/versioncontrol/cache.py", line 195, in sync
    for path,kind,action,bpath,brev in cset.get_changes():
  File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/versioncontrol/svn_fs.py", line 882, in get_changes
    repos.svn_repos_replay(root, e_ptr, e_baton, pool())
  File "/usr/lib64/python2.4/site-packages/libsvn/repos.py", line 245, in svn_repos_replay
    return apply(_repos.svn_repos_replay, args)
libsvn._core.SubversionException: ("Filesystem path 'trunk/path/to/corrupt/file' is neither a file nor a directory", 160013)

I wasted several days trying to export svn and re-create the repository etc, but continued to get the same corrupt revision.

To get around this error (note this doesn’t fix the corrupt revision - it just allows you to continue using Trac to see later revisions), edit the ‘svn_fs.py’ file listed in the trac-admin stack trace:

1
$ sudo vi /usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/versioncontrol/svn_fs.py

Go to the line mentioned in the stacktrace (line 882 in my case) :

1
repos.svn_repos_replay(root, e_ptr, e_baton, pool())

and put a try/catch around it :

1
2
3
4
try:
   repos.svn_repos_replay(root, e_ptr, e_baton, pool())
except:
   print "Warning : Revision " + str(self.rev) + " could not be read."

Now when you run trac-admin resync , it should display a warning for the corrupted revisions, but continue to sync the repository instead of crashing:

1
2
3
4
5
6
$ sudo trac-admin /path/to/your/repository/ resync
    Resyncing repository history...
    Warning : Revision 297 could not be read.
    Warning : Revision 678 could not be read.
    Warning : Revision 906 could not be read.
    1101 revisions cached. Done.