src/server/plugins/postgresql/vfs.c

branch
webdav
changeset 341
52831b82b3fd
parent 311
e676ed461b5b
child 344
70a9b945206a
--- a/src/server/plugins/postgresql/vfs.c	Sun May 08 10:41:27 2022 +0200
+++ b/src/server/plugins/postgresql/vfs.c	Sun May 08 10:46:56 2022 +0200
@@ -584,6 +584,21 @@
             lo_mode = INV_WRITE;
         }
         fd = lo_open(pg->connection, oid, lo_mode);
+        int err = 0;
+        if(fd < 0) {
+            err = 1;
+        } else if((oflags & O_TRUNC) == O_TRUNC) {
+            if(lo_truncate(pg->connection, fd, 0)) {
+                lo_close(pg->connection, fd);
+                err = 1;
+            }
+        }
+        
+        if(err) {
+            pool_free(ctx->pool, file);
+            pool_free(ctx->pool, pgfile);
+            return NULL;
+        }
     }
     
     pgfile->iscollection = iscollection;

mercurial