PTR Upload Patch
Fixes the 500 error v510 clients are seeing when they upload to the PTR.
This commit is contained in:
parent
d4913d8d43
commit
4b20e3e466
|
@ -7,6 +7,9 @@ import yaml
|
|||
# old method of getting frozen dir, doesn't work for symlinks looks like:
|
||||
# BASE_DIR = getattr( sys, '_MEIPASS', None )
|
||||
|
||||
RUNNING_CLIENT = False
|
||||
RUNNING_SERVER = False
|
||||
|
||||
RUNNING_FROM_FROZEN_BUILD = getattr( sys, 'frozen', False )
|
||||
|
||||
if RUNNING_FROM_FROZEN_BUILD:
|
||||
|
|
|
@ -3,6 +3,7 @@ import json
|
|||
import os
|
||||
|
||||
from hydrus.core import HydrusCompression
|
||||
from hydrus.core import HydrusConstants as HC
|
||||
from hydrus.core import HydrusData
|
||||
from hydrus.core import HydrusExceptions
|
||||
|
||||
|
@ -377,13 +378,60 @@ class SerialisableDictionary( SerialisableBase, dict ):
|
|||
|
||||
SERIALISABLE_TYPE = SERIALISABLE_TYPE_DICTIONARY
|
||||
SERIALISABLE_NAME = 'Serialisable Dictionary'
|
||||
SERIALISABLE_VERSION = 2
|
||||
SERIALISABLE_VERSION = 2 # this is used in the network, do not update it casually!
|
||||
|
||||
def __init__( self, *args, **kwargs ):
|
||||
|
||||
dict.__init__( self, *args, **kwargs )
|
||||
SerialisableBase.__init__( self )
|
||||
|
||||
def _GetSerialisableInfoVersion1( self ):
|
||||
|
||||
simple_key_simple_value_pairs = []
|
||||
simple_key_serialisable_value_pairs = []
|
||||
serialisable_key_simple_value_pairs = []
|
||||
serialisable_key_serialisable_value_pairs = []
|
||||
|
||||
for ( key, value ) in self.items():
|
||||
|
||||
if isinstance( key, SerialisableBase ):
|
||||
|
||||
serialisable_key = key.GetSerialisableTuple()
|
||||
|
||||
if isinstance( value, SerialisableBase ):
|
||||
|
||||
serialisable_value = value.GetSerialisableTuple()
|
||||
|
||||
serialisable_key_serialisable_value_pairs.append( ( serialisable_key, serialisable_value ) )
|
||||
|
||||
else:
|
||||
|
||||
serialisable_value = value
|
||||
|
||||
serialisable_key_simple_value_pairs.append( ( serialisable_key, serialisable_value ) )
|
||||
|
||||
|
||||
else:
|
||||
|
||||
serialisable_key = key
|
||||
|
||||
if isinstance( value, SerialisableBase ):
|
||||
|
||||
serialisable_value = value.GetSerialisableTuple()
|
||||
|
||||
simple_key_serialisable_value_pairs.append( ( serialisable_key, serialisable_value ) )
|
||||
|
||||
else:
|
||||
|
||||
serialisable_value = value
|
||||
|
||||
simple_key_simple_value_pairs.append( ( serialisable_key, serialisable_value ) )
|
||||
|
||||
|
||||
|
||||
|
||||
return ( simple_key_simple_value_pairs, simple_key_serialisable_value_pairs, serialisable_key_simple_value_pairs, serialisable_key_serialisable_value_pairs )
|
||||
|
||||
|
||||
def _GetSerialisableInfo( self ):
|
||||
|
||||
|
@ -475,6 +523,38 @@ class SerialisableDictionary( SerialisableBase, dict ):
|
|||
|
||||
|
||||
|
||||
def GetSerialisableTuple( self ):
|
||||
|
||||
# TODO: delete this around version 537
|
||||
# this is a patch to deal with me foolishly updating SerialisableDictionary without thinking that it is used in network comms
|
||||
# the server suddenly starts giving version 2 Dicts, and old clients can't handle it!
|
||||
# therefore, we are patching this to give a version 1 result if we are the server. we don't transport bytes stuff over network yet, nor store bytes in server services dict, so it is ok
|
||||
# we are doing this for version 511, so let's give lads ~26 weeks to update
|
||||
|
||||
if HC.RUNNING_SERVER:
|
||||
|
||||
serialisable_info = self._GetSerialisableInfoVersion1()
|
||||
|
||||
return ( self.SERIALISABLE_TYPE, 1, serialisable_info )
|
||||
|
||||
else:
|
||||
|
||||
if hasattr( self, '_lock' ):
|
||||
|
||||
with getattr( self, '_lock' ):
|
||||
|
||||
serialisable_info = self._GetSerialisableInfo()
|
||||
|
||||
|
||||
else:
|
||||
|
||||
serialisable_info = self._GetSerialisableInfo()
|
||||
|
||||
|
||||
return ( self.SERIALISABLE_TYPE, self.SERIALISABLE_VERSION, serialisable_info )
|
||||
|
||||
|
||||
|
||||
|
||||
SERIALISABLE_TYPES_TO_OBJECT_TYPES[ SERIALISABLE_TYPE_DICTIONARY ] = SerialisableDictionary
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ MAX_NULLIFICATION_PERIOD = 86400 * 365
|
|||
|
||||
def GenerateDefaultServiceDictionary( service_type ):
|
||||
|
||||
# don't store bytes key/value data here until ~version 537
|
||||
# the server kicks out a patched version 1 of serialisabledict, so it can't handle byte gubbins, lad
|
||||
|
||||
dictionary = HydrusSerialisable.SerialisableDictionary()
|
||||
|
||||
dictionary[ 'upnp_port' ] = None
|
||||
|
|
|
@ -25,6 +25,8 @@ try:
|
|||
|
||||
from hydrus.core import HydrusConstants as HC
|
||||
|
||||
HC.RUNNING_CLIENT = True
|
||||
|
||||
from hydrus.core import HydrusData
|
||||
from hydrus.core import HydrusGlobals as HG
|
||||
from hydrus.core import HydrusLogger
|
||||
|
|
|
@ -23,6 +23,9 @@ try:
|
|||
HydrusBoot.AddBaseDirToEnvPath()
|
||||
|
||||
from hydrus.core import HydrusConstants as HC
|
||||
|
||||
HC.RUNNING_SERVER = True
|
||||
|
||||
from hydrus.core import HydrusExceptions
|
||||
from hydrus.core import HydrusData
|
||||
from hydrus.core import HydrusGlobals as HG
|
||||
|
|
Loading…
Reference in New Issue