Skip to content

Commit

Permalink
Merge pull request #209 from ShaneIsrael/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ShaneIsrael authored Jun 28, 2023
2 parents 9e498a4 + 472161d commit c5c5ee0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<li><a href="#built-with">Built With</a></li>
</ul>
</li>
<li><a href="#changelog">Changelog</a></li>
<li>
<a href="#installation">Installation</a>
<ul>
Expand Down Expand Up @@ -140,6 +141,15 @@ Connect Fireshare to a central user directory and keep user access organised.
- [Python](https://www.python.org/)
- [Material UI](https://mui.com/)

<!--- CHANGE LOG --->

# Changelog

## v1.2.13
```
Added a catch for finding corrupt or malformed files when initiating a scan
```

<!-- GETTING STARTED -->

# Installation
Expand Down
2 changes: 1 addition & 1 deletion app/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fireshare",
"version": "1.2.12",
"version": "1.2.13",
"private": true,
"dependencies": {
"@emotion/react": "^11.9.0",
Expand Down
38 changes: 16 additions & 22 deletions app/server/fireshare/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from pathlib import Path
from sqlalchemy import func
import time
import integv

from .constants import SUPPORTED_FILE_EXTENSIONS

Expand Down Expand Up @@ -140,35 +139,30 @@ def repair_symlinks():

@cli.command()
def sync_metadata():
class corruptFileException(Exception):
pass

def checkForCorruptFile(vpath, v):
content_verf_retries = 0
while not integv.verify(open(vpath, "rb"), file_type=str(v.video.extension)):
if content_verf_retries >= 3:
logger.warn(f"There is a corrupt file in the uploads directory. Please find and remove the file!. (Look for the syslink-ed file: {vpath})\nRun the command \"stat {vpath}\" to find the offending file.")
raise corruptFileException()
content_verf_retries += 1
logger.info(f"[{content_verf_retries}/3] - Found a corrupt file: {vpath}")
logger.info("Waiting 30 seconds to try again...")
time.sleep(30)
else:
logger.info(f"File passed corruption check: {vpath}")

with create_app().app_context():
paths = current_app.config['PATHS']
videos = VideoInfo.query.filter(VideoInfo.info==None).all()
logger.info(f'Found {len(videos):,} videos without metadata')
for v in videos:
vpath = paths["processed"] / "video_links" / str(v.video_id + v.video.extension)
if Path(vpath).is_file():
info = None
while info == None:
info = util.get_media_info(vpath)
if info == None:
corruptVideoWarning = "There may be a corrupt video in your video Directory. See your logs for more info!"
if not corruptVideoWarning in current_app.config['WARNINGS']:
current_app.config['WARNINGS'].append(corruptVideoWarning)
logger.warn(f"[{v.video.path}] - There may be a corrupt file in your video directory. Or, you may be recording to the video directory and haven't finished yet.")
logger.warn(f"For more info and to find the offending file, run this command in your container: \"stat {vpath}\"")
logger.warn("I'll try to process this file again in 60 seconds...")
time.sleep(60)

if str(v.video.extension) != ".mov":
checkForCorruptFile(vpath, v)
else:
logger.info(f"Corruption Check Skipping .mov file as it cannot be validated")
info = util.get_media_info(vpath)
corruptVideoWarning = "There may be a corrupt video in your video Directory. See your logs for more info!"
if corruptVideoWarning in current_app.config['WARNINGS']:
position = current_app.config['WARNINGS'].index(corruptVideoWarning)
current_app.config['WARNINGS'].pop(position)

vcodec = [i for i in info if i['codec_type'] == 'video'][0]
duration = 0
if 'duration' in vcodec:
Expand Down
2 changes: 1 addition & 1 deletion app/server/fireshare/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_media_info(path):
data = json.loads(sp.check_output(cmd.split()).decode('utf-8'))
return data['streams']
except Exception as ex:
logger.warn('Could not extract video info', ex)
logger.warning('Could not extract video info')
return None

def create_poster(video_path, out_path, second=0):
Expand Down
1 change: 0 additions & 1 deletion app/server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ zipp==3.8.0
xxhash==3.0.0
apscheduler==3.9.1
python-ldap==3.4.3
integv==1.3.0

0 comments on commit c5c5ee0

Please sign in to comment.