Browse Source

Do not create parent directories in the GIO module

The GIO-based module will no longer attempt to create parent
directories when writing a share. Parent directories are assumed
to exist, and the module will throw an error if they do not.

It is simpler and more consistent with the behavior of the other
modules.
master
Damien Goutte-Gattat 5 years ago
parent
commit
383dc33027
  1. 36
      src/scheme-gio.c

36
src/scheme-gio.c

@ -181,37 +181,6 @@ get_file_contents(GVolume *volume,
return rc;
}
/**
* Create all the parent directories of the specified path.
*
* @param path Path to a file whose parents should be created.
*
* @return 0 if the parents were created (or already existed),
* or -1 if an error occured.
*/
static int
make_parent_directories(const char *path)
{
GFile *file, *parent;
int rc = 0;
file = g_file_new_for_path(path);
if ( (parent = g_file_get_parent(file)) ) {
char *ppath;
ppath = g_file_get_path(parent);
if ( g_mkdir_with_parents(ppath, 755) == -1 )
rc = -1;
g_free(ppath);
g_object_unref(parent);
}
g_object_unref(file);
return rc;
}
/**
* Write a file on the given volume.
*
@ -244,9 +213,8 @@ put_file_contents(GVolume *volume,
root_path = g_file_get_path(root);
full_path = g_strjoin("/", root_path, path, NULL);
if ( make_parent_directories(full_path) != -1 )
if ( write_file(full_path, buffer, len) != -1 )
rc = 0;
if ( write_file(full_path, buffer, len) != -1 )
rc = 0;
if ( was_mounted )
g_object_unref(mount);

Loading…
Cancel
Save