diff --git a/components/dfs/dfs_v1/src/dfs_file.c b/components/dfs/dfs_v1/src/dfs_file.c index 3a7e626f20..a22f7b3f31 100644 --- a/components/dfs/dfs_v1/src/dfs_file.c +++ b/components/dfs/dfs_v1/src/dfs_file.c @@ -879,7 +879,7 @@ static void copyfile(const char *src, const char *dst) return; } fd_init(&fd); - if (dfs_file_open(&fd, dst, O_WRONLY | O_CREAT) < 0) + if (dfs_file_open(&fd, dst, O_WRONLY | O_CREAT | O_TRUNC) < 0) { rt_free(block_ptr); dfs_file_close(&src_fd); diff --git a/components/dfs/dfs_v2/src/dfs_file.c b/components/dfs/dfs_v2/src/dfs_file.c index b7fd4bdcad..1e43b9fd53 100644 --- a/components/dfs/dfs_v2/src/dfs_file.c +++ b/components/dfs/dfs_v2/src/dfs_file.c @@ -1939,7 +1939,7 @@ static void copyfile(const char *src, const char *dst) dfs_file_init(&dst_file); - ret = dfs_file_open(&dst_file, dst, O_WRONLY | O_CREAT, 0); + ret = dfs_file_open(&dst_file, dst, O_WRONLY | O_CREAT | O_TRUNC, 0); if (ret < 0) { dfs_file_deinit(&dst_file);