mirror of
https://github.com/MaintainTeam/Hypatia.git
synced 2025-03-01 05:48:23 +03:00
Exclude large files from realtime scanner
This commit is contained in:
parent
8de76aad66
commit
21dfafd0af
4 changed files with 6 additions and 5 deletions
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -24,7 +24,7 @@
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
android:exported="false"/>
|
android:exported="false"/>
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name="EventReceiver"
|
android:name=".EventReceiver"
|
||||||
android:label="Theia Persistence"
|
android:label="Theia Persistence"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class MalwareScannerService extends Service {
|
||||||
case FileObserver.MOVED_TO:
|
case FileObserver.MOVED_TO:
|
||||||
case FileObserver.CLOSE_WRITE:
|
case FileObserver.CLOSE_WRITE:
|
||||||
File file = new File(path);
|
File file = new File(path);
|
||||||
if (file.exists() && file.length() > 0) {
|
if (file.exists() && file.length() > 0 && file.length() <= Utils.MAX_SCAN_SIZE_REALTIME) {
|
||||||
Set<File> filesToScan = new HashSet<>();
|
Set<File> filesToScan = new HashSet<>();
|
||||||
filesToScan.add(file);
|
filesToScan.add(file);
|
||||||
new MalwareScanner(null, getApplicationContext(), false).execute(filesToScan);
|
new MalwareScanner(null, getApplicationContext(), false).execute(filesToScan);
|
||||||
|
|
|
@ -9,7 +9,8 @@ import java.util.Set;
|
||||||
|
|
||||||
class Utils {
|
class Utils {
|
||||||
|
|
||||||
private final static int MAX_FILE_SIZE = (1000 * 1000) * 50; //50MB
|
public final static int MAX_SCAN_SIZE = (1000 * 1000) * 80; //80MB
|
||||||
|
public final static int MAX_SCAN_SIZE_REALTIME = MAX_SCAN_SIZE / 2; //40MB
|
||||||
|
|
||||||
public static Set<File> getFilesRecursive(File root) {
|
public static Set<File> getFilesRecursive(File root) {
|
||||||
Set<File> filesAll = new HashSet<>();
|
Set<File> filesAll = new HashSet<>();
|
||||||
|
@ -23,7 +24,7 @@ class Utils {
|
||||||
filesAll.addAll(filesTmp);
|
filesAll.addAll(filesTmp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (f.length() <= MAX_FILE_SIZE) {//Exclude files larger than 50MB for performance
|
if (f.length() <= MAX_SCAN_SIZE) {//Exclude files larger than limit for performance
|
||||||
filesAll.add(f);
|
filesAll.add(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue