Skip to content

Conversation

@phracek
Copy link
Contributor

@phracek phracek commented Feb 17, 2016

Signed-off-by: Petr Hracek [email protected]

@gdha gdha added the enhancement Adaptions and new features label Feb 17, 2016
@gdha gdha added this to the Rear v1.18 milestone Feb 17, 2016
gdha added a commit that referenced this pull request Feb 17, 2016
Fixes #781 Fix for removing directory in case that they are not empty
@gdha gdha merged commit 757b57b into rear:master Feb 17, 2016
@pcahyna
Copy link
Member

pcahyna commented Mar 25, 2021

Hello, @phracek @gdha , why this change? It reverts (partially) the change in 8a545d6 and risks reintroducing bug #465. The point is, when the directory is not empty, you should not remove it, because it can contain valuable data, like previous backups or backups from other machines.
I also don't see how it fixes #781 (support for S/390), since I suspect the nonempty directory is a consequence of not having support for S/390, not the cause.

@pcahyna
Copy link
Member

pcahyna commented Mar 25, 2021

More general question, the function cleanup_build_area_and_end_program and the AddExitTask in 100_mount_output_path.sh seem to have the same purpose. Why do we have both?

Similar question applies to

[[ -d $BUILD_DIR/outputfs/$NETFS_PREFIX ]] && rm -rf $v $BUILD_DIR/outputfs/$NETFS_PREFIX
[[ -d $BUILD_DIR/outputfs/$RSYNC_PREFIX ]] && rm -rf $v $BUILD_DIR/outputfs/$RSYNC_PREFIX

in usr/share/rear/output/default/980_umount_output_dir.sh although this part has not been touched by this change nor by 8a545d6. (I am asking because there seem to be way too many places where we rm -rf potentially valuable data.)

@pcahyna
Copy link
Member

pcahyna commented Mar 25, 2021

I also found that rm has a useful --one-file-system option. As ReaR does not support RHEL 5 anymore, we could start using it, unless there are some supported SLES versions that lack it (Debian 8 and Ubuntu 16.04 and RHEL 6 have it: http://manpages.ubuntu.com/manpages/xenial/man1/rm.1.html).

@jsmeix
Copy link
Member

jsmeix commented Mar 25, 2021

@pcahyna
in general ReaR has grown according to what was needed in practice
by various different contributors over the time.
So we do have lots of duplicated convoluted, obfuscated, outdated,
quick-and-dirty, and whatever else kind of "bad code" places.
I tried to clean up several of them (those places where I was mostly hit)
as good as I could (with my limited overall knowledge of the whole picture).
So when you are hit by whatever kind of "bad code" place
feel free and be brave and merciless and try to clean up the mess.
Usually things won't get worse when you do it with some reasonable care.
Miracles are not expected (i.e. you may make mistakes - that's normal).
But please add meaningful and explanatory comments to your cleaned up code
to enable others to fix and enhance your code properly if needed later, cf.
https://github.com/rear/rear/wiki/Coding-Style

@pcahyna
Copy link
Member

pcahyna commented Mar 25, 2021

@jsmeix thanks for your encouragement, but I first wanted to learn the intent of the current code (in this case, duplication of output directory removal) before attemtoting any cleanup :-)

jsmeix added a commit that referenced this pull request Jun 18, 2021
…-updated

Fix backup removal in exit task and cleanup handling of URL mountpoints:
Cleanup of temporary mount point handling, particularly for output.
Unification of mount point umount and cleanup move
to the mount_url() and umount_url() functions.
Replaced the various "rm -rf" of the mountpoint by "rmdir" which fixes
#2611
Added lazy umount in case normal umount does not succeed.
If build dir is kept (cf. KEEP_BUILD_DIR), propose a safe way to remove it
to the user via "rm -Rf --one-file-system" instead of just "rm -Rf" where
the user risks to remove everything below that mountpoint if still mounted.
Fixes also some other bugs noted in the process:
Filesystem-specific umount command not called
20359a9#r51319634
Unknown schemes considered invalid, see the discussion under
#932
Identical scripts under DUPLICITY and YUM replaced by symlinks.
Reverted
#782
that had reintroduced
#465
which got re-reported as
#2611
Reverted
#578
because it is not clear how .lockfile can exist in the
unmounted filesystem, and if it does, it is a bug.
Reverted 
d850c40
because it became meanwhile obsoleted by
a8fdc44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Adaptions and new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants