Skip to content

Commit

Permalink
Fixed 'invalid cross device link' error, occuring when moving files a…
Browse files Browse the repository at this point in the history
…cross file systems

For example /tmp and /silos are on different mounts
  • Loading branch information
Anusha Ranganathan committed Jun 12, 2012
1 parent 43dcf21 commit be63e2e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Tue Jun 12 2012
* Version: 0.4.16
* replaced os.rename with shutil.copytree as Python cannot handle moving files between file systems

Thu Apr 05 2011
* Version: 0.4.15
* Version logs added to the manifest for every create / update / delete action
Expand Down
2 changes: 1 addition & 1 deletion RecordSilo.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: RecordSilo
Version: 0.4.15
Version: 0.4.16
Summary: An adaptation of a pairtree store, each object with simple JSON keyvalue manifest and crude versioning.
Home-page: UNKNOWN
Author: Ben O'Steen, Anusha Ranganathan
Expand Down
8 changes: 8 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
python-recordsilo (0.4.16) unstable; urgency=low

* replaced os.rename with shutil.copytree as Python cannot handle moving
files between file systems (Invalid cross-device link error)

-- Anusha Ranganathan <[email protected]> Tue, 12 Jun 2012 14:15:36 +0000


python-recordsilo (0.4.15) unstable; urgency=low

* Version logs added to the manifest for every create / update / delete action
Expand Down
Binary file added dist/RecordSilo-0.4.16-py2.6.egg
Binary file not shown.
12 changes: 10 additions & 2 deletions recordsilo/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import os

from shutil import copy2
from shutil import copy2, copytree, rmtree

import simplejson

Expand Down Expand Up @@ -396,7 +396,15 @@ def move_directory_as_new_version(self, src_directory, version=None, force=False
else:
raise Exception("Cannot move a directory onto an already existing version")
version_path = os.path.join(ppath.id_to_dirpath(self.po.id, self.po.fs.pairtree_root), "__%s" % version)
os.rename(src_directory, version_path)
try:
os.rename(src_directory, version_path)
except os.error, e:
#Doing the following to avoid Invalid cross-device link error in python.
#This occurs when renaming a file if the src and dst are on different file systems
#as Python os cannot handle moving between file systems
if os.path.isdir(src_directory) and not os.path.isdir(version_path):
copytree(src_directory, version_path, symlinks=True)
rmtree(src_directory)
self._setup_version_dir(version, date)
self.manifest['date'] = date
self._read_date()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup, find_packages

setup(name="RecordSilo",
version="0.4.15",
version="0.4.16",
description="An adaptation of a pairtree store, each object with simple JSON keyvalue manifest and crude versioning.",
long_description="""An adaptation of a pairtree store, each object with simple JSON keyvalue manifest and crude versioning.
Designed to be used as a repository of harvested records from OAI-PMH based services and the like.
Expand Down

0 comments on commit be63e2e

Please sign in to comment.