Skip to content

Commit 1c1a89c

Browse files
committed
catchup update #2
1 parent 9efea2b commit 1c1a89c

File tree

6 files changed

+209
-136
lines changed

6 files changed

+209
-136
lines changed

src/backup.c

+34-17
Original file line numberDiff line numberDiff line change
@@ -335,23 +335,7 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
335335
elog(ERROR, "PGDATA is almost empty. Either it was concurrently deleted or "
336336
"pg_probackup do not possess sufficient permissions to list PGDATA content");
337337

338-
/* Calculate pgdata_bytes */
339-
for (i = 0; i < parray_num(backup_files_list); i++)
340-
{
341-
pgFile *file = (pgFile *) parray_get(backup_files_list, i);
342-
343-
if (file->external_dir_num != 0)
344-
continue;
345-
346-
if (S_ISDIR(file->mode))
347-
{
348-
current.pgdata_bytes += 4096;
349-
continue;
350-
}
351-
352-
current.pgdata_bytes += file->size;
353-
}
354-
338+
current.pgdata_bytes += calculate_datasize_of_filelist(backup_files_list);
355339
pretty_size(current.pgdata_bytes, pretty_bytes, lengthof(pretty_bytes));
356340
elog(INFO, "PGDATA size: %s", pretty_bytes);
357341

@@ -2382,3 +2366,36 @@ check_external_for_tablespaces(parray *external_list, PGconn *backup_conn)
23822366
}
23832367
}
23842368
}
2369+
2370+
/*
2371+
* Calculate pgdata_bytes
2372+
* accepts (parray *) of (pgFile *)
2373+
*/
2374+
int64
2375+
calculate_datasize_of_filelist(parray *filelist)
2376+
{
2377+
int64 bytes = 0;
2378+
int i;
2379+
2380+
/* parray_num don't check for NULL */
2381+
if (filelist == NULL)
2382+
return 0;
2383+
2384+
for (i = 0; i < parray_num(filelist); i++)
2385+
{
2386+
pgFile *file = (pgFile *) parray_get(filelist, i);
2387+
2388+
if (file->external_dir_num != 0)
2389+
continue;
2390+
2391+
if (S_ISDIR(file->mode))
2392+
{
2393+
// TODO is a dir always 4K?
2394+
bytes += 4096;
2395+
continue;
2396+
}
2397+
2398+
bytes += file->size;
2399+
}
2400+
return bytes;
2401+
}

0 commit comments

Comments
 (0)