Test sandbox program has been moved from the `TinySPARQL` (previously
`tracker`) project to `localsearch` (previously `tracker-miners`).
067e855151abc100fa6b
Null pointer checks on files returned by g_file_new_for_path and
g_file_get_child are not useful. Replace them with existance
check for existing files and drop them for files that are yet
to be created.
These checks tests files nested in a file structure. They are
only used for checking and nothing else in their respective
functions. They are also logically wrong, but that is addressed in
the next commit.
Add a helper function that appends a bracketed number to the end of a
file name, and can also detect previous numbers. Adjust functions in
file-operations and file-util to use it for handling conflicts. Also,
add unittests for it.
When checking file names for previous copy appendices, check the length
of the appendix. Without this names such as "file (Copy 2 Disk)" would
have triggered appendix detection and resulted in "file (Copy 3)" as a
file name.
Add unittests to cover this case. Also adjust long number unittest to
fit in 32 bits.
Duplication appendices added start with a space, so when parsing
previous names make sure that such a space exists too.
Also, fix incorrect unittest and use the term appendix more uniformly.
To avoid needless string copies, make nautilus_file_get_metadata return
a const char* rather then a string copy that has to be freed. Adjust
usages accordingly.
To avoid needless string copies, make nautilus_file_get_name return a
const char* rather then a string copy that has to be freed. Adjust usage
accordingly.
Their names are misleading: the list itself is not refcounted.
This misconception is likely how some memory leaks have been
introduced in nautilus_restore_files_from_trash() and in
properties_cb(). Both leaks are therefore fixed as part of
this commit by employing autocleanup in the first case and
stack allocation in the second case.
To not need to include a .c file in test-file-utilities, expose
nautilus_file_new_from_filename in nautilus-file-private.h and adjust
the includes accordingly.
Integrate `eel_str_get_common_prefix` as `nautilus_filename_get_common_prefix`
into filename utilities. Rename the unittest to reflect this.
eel-string.h is no longer needed with this change, so it is removed.
Unittests are more straightforward to run than the eel self-check
mechanism. This also allows removing eel dependencies. The tests
are split up to make them more comprehensible.
Turn the file duplication testing code into a dedicated unittest.
Unittests are more straightforward to run than the eel self-check
mechanism. This also allows dropping eel dependencies and reduces
the size of the file-operations file.
The concrete duplication syntax is abstracted away with a macro for
better readability of the comparisons.
The new `nautilus_filename_get_extension` function is similar to the
previous `eel_filename_get_extension_offset` function, but differs
in some ways:
* It does not accept NULL
* It returns a pointer to \0 rather than NULL when no extension
can be found.
* It detects .tar.* extensions without needing a maintained list.
In the one place it was used, replace `nautilus_file_get_extension`
by instead calling `nautilus_filename_get_extension` on the file name.
Migrate usages of the previous eel function to use the new function
and remove the eel function from the header file (It is still used
in the .c file).
Also unittests.
`nautilus_filename_shorten_base` shortens a file name to fit within a
certain limit, by trimming the base part of the filename. It can thus
be used to shorten file name without mangling extensions and other
suffixes. It gets used in two places where a file operation can lead to
a file name conflict and a suffix is added to resolve it.
The method is placed in a new 'filename-utilities' file to allow creating a
unittest for it, as well as in preparation for moving other file name functions
there.
These were previously commented out in `file-directory.c`. They
couldn't have functioned anymore, as setting arbitrary metadata values
is prevented by the nautilus-metadata hash table.
By reusing already existing metadata tags, that don't have any effect
on the file they are used on, these tests can be reactivated.
In order to work in test environments without gvfsd-metadata running,
bypass GIO and set metadata directly.
Unittests are more straightforward to run than the eel self-check
mechanism. This also allows removing eel dependencies. The tests
are split up to make them more comprehensible.