mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-19 19:10:54 +00:00
Use sys.platform instead of os.name
mypy only recognizes sys.platform
This commit is contained in:
parent
523960bc9f
commit
0221fc357b
7 changed files with 21 additions and 33 deletions
|
@ -16,6 +16,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Radicale. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import errno
|
||||
import os
|
||||
import pickle
|
||||
import sys
|
||||
|
@ -76,15 +77,12 @@ class CollectionPartUpload(CollectionPartGet, CollectionPartCache,
|
|||
raise ValueError(
|
||||
"Failed to store item %r in temporary collection %r: %s" %
|
||||
(uid, self.path, e)) from e
|
||||
href_candidate_funtions = []
|
||||
if os.name == "posix" or sys.platform == "win32":
|
||||
href_candidate_funtions.append(
|
||||
lambda: uid if uid.lower().endswith(suffix.lower())
|
||||
else uid + suffix)
|
||||
href_candidate_funtions.extend((
|
||||
href_candidate_funtions = [
|
||||
lambda: uid if uid.lower().endswith(suffix.lower())
|
||||
else uid + suffix,
|
||||
lambda: radicale_item.get_etag(uid).strip('"') + suffix,
|
||||
lambda: radicale_item.find_available_uid(hrefs.__contains__,
|
||||
suffix)))
|
||||
lambda: radicale_item.find_available_uid(
|
||||
hrefs.__contains__, suffix)]
|
||||
href = f = None
|
||||
while href_candidate_funtions:
|
||||
href = href_candidate_funtions.pop(0)()
|
||||
|
@ -101,7 +99,8 @@ class CollectionPartUpload(CollectionPartGet, CollectionPartCache,
|
|||
break
|
||||
except OSError as e:
|
||||
if href_candidate_funtions and (
|
||||
os.name == "posix" and e.errno == 22 or
|
||||
sys.platform != "win32" and
|
||||
e.errno == errno.EINVAL or
|
||||
sys.platform == "win32" and e.errno == 123):
|
||||
continue
|
||||
raise
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue