Skip to content

Commit

Permalink
Do not create corrupt RDS file if the object to serialize does not exist
Browse files Browse the repository at this point in the history
(saveRDS, PR#17358).


git-svn-id: https://svn.r-project.org/R/trunk@74238 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
kalibera committed Feb 8, 2018
1 parent b3ccff1 commit 9245829
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/library/base/R/serialize.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# File src/library/base/R/serialize.R
# Part of the R package, https://www.R-project.org
#
# Copyright (C) 1995-2017 The R Core Team
# Copyright (C) 1995-2018 The R Core Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -22,6 +22,7 @@ saveRDS <-
{
if(is.character(file)) {
if(file == "") stop("'file' must be non-empty string")
object <- object # do not create corrupt file if object does not exist
mode <- if(ascii %in% FALSE) "wb" else "w"
con <- if (is.logical(compress))
if(compress) gzfile(file, mode) else file(file, mode)
Expand Down

0 comments on commit 9245829

Please sign in to comment.