Welcome to mirror list, hosted at ThFree Co, Russian Federation.

0-byte-files.sh « addons - github.com/nextcloud/vm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 892599ccc77545654f9a74a1c7405f9feda1a4c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash

# T&M Hansson IT AB © - 2022, https://www.hanssonit.se/
true
SCRIPT_NAME="Check for 0-Byte files"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)

filesystems[0]="$NCDATA"
cd "$NCDATA"

emSub="Warning: Nextcloud contains 0-Byte files!"

# Info
msg_box "We will now scan $NCDATA for files that are 0-Byte.

A 0-Byte file means that it's empty and probably corrupted/not usable. If you see files that are of importance in this list, you should report it immediately to $ISSUES.

The scan may take very long time depending on the speed of your disks, and the amount of files."

countdown "The scan starts in 3 seconds..." "3"

print_text_in_color "$ICyan" "Scan in progress, please be patient..."

# Function
for fs in "${filesystems[@]}"
do
    while IFS= read -d '' -r
    do
        arr+=( "$REPLY" )
    done < <(find "$fs" -mindepth 3 -size 0 -print0)
done


# TODO
# Remove known 0-byte files
# Everything in appdata isn't important
# NEWARR="$(echo ${arr[*]} | sed s/'appdata'//)"

# Notify!
if [ -n "${arr[*]}" ]
then
    send_mail "$emSub" "${arr[*]}"
    msg_box "$emSub

Please see files in red when you hit OK."
    for each in "${arr[@]}"
    do
      print_text_in_color "$IRed" "$each"
    done
fi