Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

just finds segments when storage full

rorycleardc35d52ccc01
diff --git a/clearcam/ViewController.m b/clearcam/ViewController.m
index caf6eab..dc2c3c4 100644
--- a/clearcam/ViewController.m
+++ b/clearcam/ViewController.m
@@ -28,7 +28,7 @@
@property (nonatomic, strong) NSMutableArray *current_segment_squares;
@property (nonatomic, strong) NSLock *segmentLock;
-#define MIN_FREE_SPACE_MB 21200 //threshold to start deleting
+#define MIN_FREE_SPACE_MB 21100 //threshold to start deleting
@end
@@ -486,14 +486,35 @@ NSMutableDictionary *classColorMap;
- (void)ensureFreeDiskSpace {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
- double freeSpace = (double)[[[[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil] objectForKey:NSFileSystemFreeSize] unsignedLongLongValue] / (1024.0 * 1024.0 * 1024.0);
- NSLog(@"Current free space: %.2f GB", freeSpace);
+ double freeSpace = (double)[[[[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil] objectForKey:NSFileSystemFreeSize] unsignedLongLongValue] / (1024.0 * 1024.0);
+ NSLog(@"Current free space: %.2f MB", freeSpace);
if(freeSpace < MIN_FREE_SPACE_MB){
NSLog(@"NOT ENOUGH SPACE!");
+ [self getAllDayEntitiesInContext:self.fileServer.context];
}
});
}
+- (void)getAllDayEntitiesInContext:(NSManagedObjectContext *)context {
+ NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"DayEntity"];
+
+ NSError *fetchError = nil;
+ NSArray *dayEntities = [context executeFetchRequest:fetchRequest error:&fetchError];
+
+ if (fetchError) {
+ NSLog(@"Failed to fetch DayEntity objects: %@", fetchError.localizedDescription);
+ return;
+ }
+
+ // Loop through all fetched objects and delete them
+ for (NSManagedObject *dayEntity in dayEntities) {
+ NSLog(@"day entity found: %@",[dayEntity valueForKey:@"date"]);
+ for(NSManagedObject *segmentEntity in [dayEntity valueForKey:@"segments"]){
+ NSLog(@"\t segment found %@",[segmentEntity valueForKey:@"url"]);
+ }
+ }
+}
+
- (void)captureOutput:(AVCaptureOutput *)output didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
@try {
if (self.isRecording && self.assetWriter.status == AVAssetWriterStatusWriting) {