diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2015-05-07 15:22:28 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2015-05-07 15:22:28 +0200 |
commit | da579f5153f7fa1108091fc18b0761e7a0581c33 (patch) | |
tree | ebcfceb3bd98cdd0a93f56eb7d6e38f013c11ad5 /pgfuse.c | |
parent | 8ac849f21ed34c447d7744cdaf76c3e10d8045cc (diff) | |
download | pgfuse-da579f5153f7fa1108091fc18b0761e7a0581c33.tar.gz pgfuse-da579f5153f7fa1108091fc18b0761e7a0581c33.tar.bz2 |
fixed the rename problem (EEXIST if the destination file exists is
wrong, the destination file should get all data and metadata from
the source file)
Diffstat (limited to 'pgfuse.c')
-rw-r--r-- | pgfuse.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -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 */ |