mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	Improved error message if the server can't read session recordings. (#4363)
This commit is contained in:
		
							parent
							
								
									8b81ee564c
								
							
						
					
					
						commit
						13c0afbc1e
					
				
					 2 changed files with 9 additions and 4 deletions
				
			
		| 
						 | 
					@ -1025,11 +1025,11 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
 | 
				
			||||||
                if (domain.sessionrecording.filepath) { recordingsPath = domain.sessionrecording.filepath; } else { recordingsPath = parent.parent.recordpath; }
 | 
					                if (domain.sessionrecording.filepath) { recordingsPath = domain.sessionrecording.filepath; } else { recordingsPath = parent.parent.recordpath; }
 | 
				
			||||||
                if (recordingsPath == null) return;
 | 
					                if (recordingsPath == null) return;
 | 
				
			||||||
                fs.readdir(recordingsPath, function (err, files) {
 | 
					                fs.readdir(recordingsPath, function (err, files) {
 | 
				
			||||||
                    if (err != null) return;
 | 
					                    if (err != null) { try { ws.send(JSON.stringify({ action: 'recordings', error: 1, tag: command.tag })); } catch (ex) { } return; }
 | 
				
			||||||
                    if ((command.limit == null) || (typeof command.limit != 'number')) {
 | 
					                    if ((command.limit == null) || (typeof command.limit != 'number')) {
 | 
				
			||||||
                        // Send the list of all recordings
 | 
					                        // Send the list of all recordings
 | 
				
			||||||
                        db.GetEvents(['recording'], domain.id, function (err, docs) {
 | 
					                        db.GetEvents(['recording'], domain.id, function (err, docs) {
 | 
				
			||||||
                            if (err != null) return;
 | 
					                            if (err != null) { try { ws.send(JSON.stringify({ action: 'recordings', error: 2, tag: command.tag })); } catch (ex) { } return; }
 | 
				
			||||||
                            for (var i in docs) {
 | 
					                            for (var i in docs) {
 | 
				
			||||||
                                delete docs[i].action; delete docs[i].etype; delete docs[i].msg; // TODO: We could make a more specific query in the DB and never have these.
 | 
					                                delete docs[i].action; delete docs[i].etype; delete docs[i].msg; // TODO: We could make a more specific query in the DB and never have these.
 | 
				
			||||||
                                if (files.indexOf(docs[i].filename) >= 0) { docs[i].present = 1; }
 | 
					                                if (files.indexOf(docs[i].filename) >= 0) { docs[i].present = 1; }
 | 
				
			||||||
| 
						 | 
					@ -1039,7 +1039,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        // Send the list of most recent recordings, up to 'limit' count
 | 
					                        // Send the list of most recent recordings, up to 'limit' count
 | 
				
			||||||
                        db.GetEventsWithLimit(['recording'], domain.id, command.limit, function (err, docs) {
 | 
					                        db.GetEventsWithLimit(['recording'], domain.id, command.limit, function (err, docs) {
 | 
				
			||||||
                            if (err != null) return;
 | 
					                            if (err != null) { try { ws.send(JSON.stringify({ action: 'recordings', error: 2, tag: command.tag })); } catch (ex) { } return; }
 | 
				
			||||||
                            for (var i in docs) {
 | 
					                            for (var i in docs) {
 | 
				
			||||||
                                delete docs[i].action; delete docs[i].etype; delete docs[i].msg; // TODO: We could make a more specific query in the DB and never have these.
 | 
					                                delete docs[i].action; delete docs[i].etype; delete docs[i].msg; // TODO: We could make a more specific query in the DB and never have these.
 | 
				
			||||||
                                if (files.indexOf(docs[i].filename) >= 0) { docs[i].present = 1; }
 | 
					                                if (files.indexOf(docs[i].filename) >= 0) { docs[i].present = 1; }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2728,6 +2728,7 @@
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                case 'recordings': {
 | 
					                case 'recordings': {
 | 
				
			||||||
                    p52recordings = message.events;
 | 
					                    p52recordings = message.events;
 | 
				
			||||||
 | 
					                    if (message.error != null) { p52recordings = message.error; }
 | 
				
			||||||
                    updateRecordings();
 | 
					                    updateRecordings();
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					@ -2986,7 +2987,7 @@
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        case 'recording': {
 | 
					                        case 'recording': {
 | 
				
			||||||
                            if (p52recordings != null) { p52recordings.unshift(message.event); message.event.present = 1; updateRecordings(); }
 | 
					                            if ((p52recordings != null) && (typeof p52recordings == 'object')) { p52recordings.unshift(message.event); message.event.present = 1; updateRecordings(); }
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        case 'userWebState': {
 | 
					                        case 'userWebState': {
 | 
				
			||||||
| 
						 | 
					@ -15943,6 +15944,10 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (p52recordings == null) {
 | 
					            if (p52recordings == null) {
 | 
				
			||||||
                x += '<div style=width:100%;text-align:center;margin-top:20px><i>' + "Loading..." + '</i></div>';
 | 
					                x += '<div style=width:100%;text-align:center;margin-top:20px><i>' + "Loading..." + '</i></div>';
 | 
				
			||||||
 | 
					            } else if (typeof p52recordings == 'number') {
 | 
				
			||||||
 | 
					                if (p52recordings == 1) { x += '<div style=width:100%;text-align:center;margin-top:20px><i>' + "Server is unable to read from the recordings folder." + '</i></div>'; }
 | 
				
			||||||
 | 
					                else if (p52recordings == 2) { x += '<div style=width:100%;text-align:center;margin-top:20px><i>' + "Server is unable to get recordings from the database." + '</i></div>'; }
 | 
				
			||||||
 | 
					                else { x += '<div style=width:100%;text-align:center;margin-top:20px><i>' + "An unknown error occured." + '</i></div>'; }
 | 
				
			||||||
            } else if (p52recordings.length == 0) {
 | 
					            } else if (p52recordings.length == 0) {
 | 
				
			||||||
                x += '<div style=width:100%;text-align:center;margin-top:20px><i>' + "No recordings." + '</i></div>';
 | 
					                x += '<div style=width:100%;text-align:center;margin-top:20px><i>' + "No recordings." + '</i></div>';
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue