summaryrefslogtreecommitdiff
path: root/pgfuse.c
diff options
context:
space:
mode:
Diffstat (limited to 'pgfuse.c')
-rw-r--r--pgfuse.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/pgfuse.c b/pgfuse.c
index c77d70f..c4e0ebd 100644
--- a/pgfuse.c
+++ b/pgfuse.c
@@ -1346,9 +1346,20 @@ static int pgfuse_rename( const char *from, const char *to )
PSQL_ROLLBACK( conn ); RELEASE( conn );
return 0;
} else {
- /* otherwise bail out */
- PSQL_ROLLBACK( conn ); RELEASE( conn );
- return -EEXIST;
+ /* otherwise make source file disappear and
+ * destination file contain the same data
+ * as the source one (preferably atomic because
+ * of rename/lockfile tricks)
+ */
+ res = psql_rename_to_existing_file( conn, from_id, to_id, from, to );
+ if( res < 0 ) {
+ PSQL_ROLLBACK( conn ); RELEASE( conn );
+ return res;
+ }
+
+ PSQL_COMMIT( conn ); RELEASE( conn );
+
+ return res;
}
}
/* TODO: handle all other cases */