Skip to content

Commit

Permalink
Use mtime instead of time
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Nov 18, 2018
1 parent acad675 commit 3a6f9c4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions postprocess
Expand Up @@ -8,7 +8,6 @@

import datetime
import glob
import hashlib
import os
import random
import re
Expand Down Expand Up @@ -193,11 +192,10 @@ def finalise(config, root_folder):

# call(['chmod', '-R', 'go+rw', '/destination'])

with open('/opt/postprocess') as file_:
hash_ = hashlib.sha256(file_.read()).hexdigest()
mtime = time.ctime(os.path.getmtime('/opt/postprocess'))

print('Welcome to scaned images document to paperless.')
print('Hash: ' + hash_)
print('Script time: ' + mtime)
while True:
print("Scan")
for config_file_name in glob.glob('/source/*/config.yaml'):
Expand All @@ -211,7 +209,7 @@ while True:
with open(config_file_name) as config_file:
config = yaml.load(config_file.read())

if os.path.exists(os.path.join(root_folder, 'error.yaml')) and config.get('hash') == hash_:
if os.path.exists(os.path.join(root_folder, 'error.yaml')) and config.get('mtime') == mtime:
print("On error")
continue

Expand All @@ -220,7 +218,7 @@ while True:
if not os.path.exists(os.path.join(root_folder, 'waiting')):
print("Finalise")

config['hash'] = hash_
config['mtime'] = mtime
with open(config_file_name, 'w') as config_file:
config_file.write(yaml.dump(config))

Expand All @@ -237,7 +235,7 @@ while True:
if ok:
print("Transform")

config['hash'] = hash_
config['mtime'] = mtime
with open(config_file_name, 'w') as config_file:
config_file.write(yaml.dump(config))

Expand Down

0 comments on commit 3a6f9c4

Please sign in to comment.